Giter VIP home page Giter VIP logo

Comments (6)

mxgrn avatar mxgrn commented on August 24, 2024

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 [email protected] 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"=>"pages__edit_window__edit_form", "method"=>"netzkeSubmit", "data"=>[{"data"=>"{"id":"2","name":"testpage","url":"www.example.com","user__name":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"=>"pages__edit_window__edit_form", "method"=>"netzkeSubmit", "data"=>[{"data"=>"{"id":"2","name":"testpage","url":"www.example.com","user__name":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.

from netzke-core.

denispeplin avatar denispeplin commented on August 24, 2024

Added, restarted server, reloaded page. Still does not work. Netzke keeps passing user_id as user_name parameter.

from netzke-core.

mxgrn avatar mxgrn commented on August 24, 2024

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 [email protected] 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.

from netzke-core.

denispeplin avatar denispeplin commented on August 24, 2024

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.

from netzke-core.

mxgrn avatar mxgrn commented on August 24, 2024

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!

from netzke-core.

denispeplin avatar denispeplin commented on August 24, 2024

I'm almost sure it will be more feedback :)

Thank you!

from netzke-core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.