Allow anon controlled metapurses

This commit is contained in:
TheNeedful-DO 2024-03-25 13:59:35 +00:00
parent 33ff0e4978
commit 1410583789
4 changed files with 11 additions and 6 deletions

View File

@ -1,5 +1,5 @@
class Metapurse < ActiveRecord::Base
belongs_to :user
belongs_to :user, optional: true
def icpswap_pool_data_raw
icpswap_pool_data_raw = `dfx --identity anonymous canister --network=ic call ggzvv-5qaaa-aaaag-qck7a-cai getAllPools`
end

View File

@ -38,11 +38,11 @@ class MetapursePolicy
end
def create?
@user.admin? || @user.signed_in?
@user.admin? || @user.signed_in? || true
end
def new?
@user.admin? || @user.signed_in?
@user.admin? || @user.signed_in? || true
end
def edit?
@ -50,7 +50,7 @@ class MetapursePolicy
end
def update?
@user.admin? || @metapurse.user == @user
@user.admin? || @metapurse.user == @user || @metapurse.user == nil
end
def destroy?

View File

@ -0,0 +1,5 @@
class ChangeColumnUserIdOnMetaPurse < ActiveRecord::Migration[7.1]
def change
change_column :metapurses, :user_id, :integer, null: true
end
end

View File

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.1].define(version: 2024_03_10_122622) do
ActiveRecord::Schema[7.1].define(version: 2024_03_25_135707) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -112,7 +112,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_03_10_122622) do
t.text "data"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "user_id", null: false
t.integer "user_id"
t.index ["user_id"], name: "index_metapurses_on_user_id"
end