2012-10-14 2 views
1

을 nil의 자원을 얻을 내가 가진 전체 흐름과 나는 그것을 발견했습니다 controller_resource.rb 때 우리는 #build_resource에 도달 :load_resource 내 컨트롤러에서

def build_resource 
    resource = resource_base.new(resource_params || {}) 
    assign_attributes(resource) 
end 

여기에 resourcenil입니다. 정상입니까? 내가 뭘 놓치고있어? 그것은 행동 만들기와 관련된 내 문제와 관련이 있습니까? 여기에 편집

는 POST 만들고 호출하는 동안 내가 가진 내 ability.rb

class Ability 
    include CanCan::Ability 

    def initialize(user) 
    # Define abilities for the passed in user here. For example: 

    # check if the user is registered or a guest user (not logged in) 
    if user.present? 

     if user.any_role? :super_admin 
     can :manage, :all 
     end 

     if user.any_role? :admin 
     can :manage, [User, Institution, Project, Order] 
     end 

     if user.any_role? :user 
     can :show, Project 
     can [:add, :change], :cart 
     can [:create, :show], Order, :user_id => user.id 
     can :download, UrlConnector 
     end 

    end 
    end 
end 

편집 2

입니다 :

resource_base: User 
resource_class: User 
@params: {"user"=>{"email"=>"[email protected]"}, "controller"=>"users", "action"=>"create"} 
:

RSpec에 환경에서 superadmin 또는 admin 같은 브라우저에서

, 그것은 동일합니다 :

resource_base: User 
resource_class: User 
@params: {"utf8"=>"✓", "authenticity_token"=>"95qQ4H/+CLU96jCIO6U/YtgIQ5zWxE7pg0BedVMPSGk=", "user"=>{"email"=>"[email protected]", "password"=>"264763", "password_confirmation"=>"264763", "ragionesociale"=>"fff", "partitaiva"=>"12345678901", "address"=>"via plutarco, 36", "city"=>"Manduria", "cap"=>"74024", "phone"=>"099979456", "role_ids"=>["3"]}, "commit"=>"Create User", "action"=>"create", "controller"=>"users"} 
+0

의 마지막 보석으로 캉캉를 배치하려고? – AnkitG

+0

@AnkitG 확실! 방금 추가되었습니다. 감사! – enricostn

+0

컨트롤러의 이름은 무엇입니까? –

답변

1

당신은 또한`ability.rb` 붙여 넣을 수 Gemfile

관련 문제