Closed denispeplin closed 11 years ago
It's a common mistake. Just add :user_id to the attr_accessible list.
Sent from my iPhone
On 22 jan. 2013, at 14:20, Denis notifications@github.com wrote:
I created two models without explicitly specifying associations in Netzke.
class User < ActiveRecord::Base attr_accessible :email, :name has_many :pages end
class Page < ActiveRecord::Base belongs_to :user attr_accessible :name, :url end
class Pages < Netzke::Basepack::Grid def configure(c) super c.model = "Page" end end When I'm editing Page, it does update all the attributes except User. I selected User from drop-down list, but its parameter passed to netzke controller looks incorrect: \"user__name\":1 and in result user_id after updating is nil.
I've put code into repository: https://github.com/denispeplin/extjs_tut/tree/ne
Post parameters:
Started POST "/netzke/direct/?authenticity_token=BaQAb8Gnadh6G3SkUZyY1nyA3S6fJACWEdwZN4FQZDI%3D" for 127.0.0.1 at 2013-01-22 10:08:18 +0400 Processing by NetzkeController#direct as HTML Parameters: {"act"=>"pagesedit_window__edit_form", "method"=>"netzkeSubmit", "data"=>[{"data"=>"{\"id\":\"2\",\"name\":\"testpage\",\"url\":\"www.example.com\",\"username\":1,\"created_at\":\"2013-01-21 12:19:56\",\"updated_at\":\"2013-01-22 05:01:39\"}"}], "type"=>"rpc", "tid"=>5, "authenticity_token"=>"BaQAb8Gnadh6G3SkUZyY1nyA3S6fJACWEdwZN4FQZDI=", "netzke"=>{"act"=>"pagesedit_window__edit_form", "method"=>"netzkeSubmit", "data"=>[{"data"=>"{\"id\":\"2\",\"name\":\"testpage\",\"url\":\"www.example.com\",\"username\":1,\"created_at\":\"2013-01-21 12:19:56\",\"updated_at\":\"2013-01-22 05:01:39\"}"}], "type"=>"rpc", "tid"=>5}} Not sure it is netzke-core issue, maybe it is just component does not work properly.
— Reply to this email directly or view it on GitHub.
Added, restarted server, reloaded page. Still does not work. Netzke keeps passing user_id
as user_name
parameter.
This is intended - a foreign key value is always passed as a value for assoc column. Can you post your final models code?
Sent from my iPhone
On 22 jan. 2013, at 15:22, Denis notifications@github.com wrote:
Added, restarted server, reloaded page. Still does not work. Netzke keeps passing user_id as user_name parameter.
— Reply to this email directly or view it on GitHub.
That was right request! Somehow I mistakenly put this :user_id
to User
model itself.
So now my Page model looks like:
class Page < ActiveRecord::Base
belongs_to :user
attr_accessible :name, :url, :user_id
end
And it works!
Thank you!
Just one thing that is probably wrong: when I' working with standard Rails, and if its need to mass-assign some protected attribute, it will complain loudly, raising an exception. But Netzke does not even displays a warning.
Just one thing that is probably wrong: when I' working with standard Rails, and if its need to mass-assign some protected attribute, it will complain loudly, raising an exception. But Netzke does not even displays a warning.
I agree, this should be fixed (in Basepack). Working on it right now. Thanks for all your constructive feedback so far, looking forward for more!
I'm almost sure it will be more feedback :)
Thank you!
I created two models without explicitly specifying associations in Netzke.
When I'm editing Page, it does update all the attributes except User. I selected User from drop-down list, but its parameter passed to netzke controller looks incorrect:
\"user__name\":1
and in resultuser_id
after updating isnil
.I've put code into repository: https://github.com/denispeplin/extjs_tut/tree/ne (uses netzke from gem in this tag, but I also tried with current netzke, same issue).
Post parameters:
Not sure it is netzke-core issue, maybe it is just component does not work properly.