Comments (6)
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
endclass Page < ActiveRecord::Base
belongs_to :user
attr_accessible :name, :url
endclass 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.
Added, restarted server, reloaded page. Still does not work. Netzke keeps passing user_id
as user_name
parameter.
from netzke-core.
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.
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.
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.
I'm almost sure it will be more feedback :)
Thank you!
from netzke-core.
Related Issues (20)
- Dynamic component loading broken HOT 3
- Compatibility with Rails asset pipeline or a CDN HOT 2
- undefined method `current_user' for Netzke::Core:Module HOT 2
- Assigning icon to actions indirectly HOT 1
- Make FeedbackGhost delay configurable HOT 1
- Overriding scope in component declaration has no effect HOT 1
- Dependent model saving HOT 1
- Ext location configure HOT 1
- can't use Ext.form.panel with directSubmit type to directly communicate with endpoint HOT 1
- endpoint response auto convert params key to camelize HOT 1
- Netzke alternative for rails fields_for to manage has_many relation HOT 1
- Status 4.2 integration? HOT 7
- Not effect on rails 4
- Netzke can not work
- netzke 0.8.4 can not work on rails 4.0.2 HOT 1
- Couldn't load component cmp1 error when dynamically loading tab in workspace HOT 3
- Upgrading to sencha 5? HOT 2
- undefined method `attr_accessible' in index.html.erb HOT 2
- Actions can not be added to menu HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from netzke-core.