yesterday, i make a demo with Rails2.2.2. ------------------------------- model : Movie ------------------------------- class Movie < ActiveRecord::Base has_many :releases, :dependent => :destroy validates_presence_of :title end --------------------------------- model: Release --------------------------------- class Release < ActiveRecord::Base belongs_to :movie validates_presence_of :movie_id, :format, :released_on def to_s [self.format, released_on.to_s(:short)].join('' - '') end end ------------------------------------------- controller: release_controller ------------------------------------------- class ReleasesController < ApplicationController def show @release = Release.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @release } end end end -------------------------------------------------- app/views/release/show.html.erb -------------------------------------------------- <p> <b>Movie:</b> <%=h @release.movie_id %> </p> <p> <b>Format:</b> <%=h @release.format %> </p> <p> <b>Released on:</b> <%=h @release.released_on %> </p> <%= link_to ''Edit'', edit_release_path(@release) %> | <%= link_to ''Back'', releases_path %> it''s correct, it works ! but , when i modify the show page as following: <p> <b>Movie:</b> <%=h @release.movie.title %> </p> <p> <b>Format:</b> <%=h @release.format %> </p> <p> <b>Released on:</b> <%=h @release.released_on %> </p> <%= link_to ''Edit'', edit_release_path(@release) %> | <%= link_to ''Back'', releases_path %> there is have a error. "Attempt to call private method" --- format Could u help me ? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Tue, Dec 16, 2008 at 1:36 AM, 浩翔 <blackanger.Z-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> there is have a error. "Attempt to call private method" --- > formatSee: <http://wiki.rubyonrails.org/rails/pages/ReservedWords> -- the "reported to cause trouble" section includes ''format''. You might want to rename that attribute of your model. HTH, -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thank you. I know the ''format'' cause trouble, it''s a private method , cause stop calling method_missing, I change ''format'' to ''formater'' or other form, it''s be fine. but why this is good : -------------------------------------------------- app/views/release/show.html.erb -------------------------------------------------- <p> <b>Movie:</b> <%=h @release.movie_id %> </p> <p> <b>Format:</b> <%=h @release.format %> </p> <p> <b>Released on:</b> <%=h @release.released_on %> </p> <%= link_to ''Edit'', edit_release_path(@release) %> | <%= link_to ''Back'', releases_path %> Could u help me understand it ? On Dec 16, 8:52 pm, "Hassan Schroeder" <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Tue, Dec 16, 2008 at 1:36 AM, 浩翔 <blackange...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > there is have a error. "Attempt to call private method" --- > > format > > See: <http://wiki.rubyonrails.org/rails/pages/ReservedWords> -- the > "reported to cause trouble" section includes ''format''. > > You might want to rename that attribute of your model. > > HTH, > -- > Hassan Schroeder ------------------------ hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Did you mean: You got the error in the Model, but it was worked in the View? Maybe you can try this in the Model: self[:format] replace self.format On Wed, Dec 17, 2008 at 5:34 PM, 浩翔 <blackanger.Z-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Thank you. > > I know the ''format'' cause trouble, it''s a private method , cause > stop calling method_missing, > I change ''format'' to ''formater'' or other form, it''s be fine. > > but why this is good : > -------------------------------------------------- > app/views/release/show.html.erb > -------------------------------------------------- > <p> > <b>Movie:</b> > <%=h @release.movie_id %> > </p> > > <p> > <b>Format:</b> > <%=h @release.format %> > </p> > > <p> > <b>Released on:</b> > <%=h @release.released_on %> > </p> > > <%= link_to ''Edit'', edit_release_path(@release) %> | > <%= link_to ''Back'', releases_path %> > > > Could u help me understand it ? > > > > > On Dec 16, 8:52 pm, "Hassan Schroeder" <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > On Tue, Dec 16, 2008 at 1:36 AM, 浩翔 <blackange...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > there is have a error. "Attempt to call private method" --- > > > format > > > > See: <http://wiki.rubyonrails.org/rails/pages/ReservedWords> -- the > > "reported to cause trouble" section includes ''format''. > > > > You might want to rename that attribute of your model. > > > > HTH, > > -- > > Hassan Schroeder ------------------------ hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > > >-- TWRUG Blog: http://blog.rubyonrails.org.tw CFC on Rails: http://zusocfc.blogspot.com Only two surfaces of a box: http://blog.pixnet.net/zusocfc --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thank you. I know the issue. sefl[:format] is good. but i dont'' understand why it reported the error : "Attempt to call private method" in View page, when i called show action. I know the column ''format'' will be cause trouble. beacuse all of instance variable has the private method named ''format'', right ? but why it is good as following : -------------------------------------------------- app/views/release/show.html.erb -------------------------------------------------- <p> <b>Movie:</b> <%=h @release.movie_id %> </p> <p> <b>Format:</b> <%=h @release.format %> </p> <p> <b>Released on:</b> <%=h @release.released_on %> </p> <%= link_to ''Edit'', edit_release_path(@release) %> | <%= link_to ''Back'', releases_path %> it is good . but when i changed <%=h @release.movie_id %> to < %=h @release.movie.title %>, when i called show action , it reported a error :"Attempt to call private method"( this line: <%=h @release.format %>) how can to explain it ? thank you. On Dec 17, 6:52 pm, CFC <zuso...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Did you mean: You got the error in the Model, but it was worked in the View? > > Maybe you can try this in the Model: > > self[:format] replace self.format > > > > On Wed, Dec 17, 2008 at 5:34 PM, 浩翔 <blackange...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Thank you. > > > I know the ''format'' cause trouble, it''s a private method , cause > > stop calling method_missing, > > I change ''format'' to ''formater'' or other form, it''s be fine. > > > but why this is good : > > -------------------------------------------------- > > app/views/release/show.html.erb > > -------------------------------------------------- > > <p> > > <b>Movie:</b> > > <%=h @release.movie_id %> > > </p> > > > <p> > > <b>Format:</b> > > <%=h @release.format %> > > </p> > > > <p> > > <b>Released on:</b> > > <%=h @release.released_on %> > > </p> > > > <%= link_to ''Edit'', edit_release_path(@release) %> | > > <%= link_to ''Back'', releases_path %> > > > Could u help me understand it ? > > > On Dec 16, 8:52 pm, "Hassan Schroeder" <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > > > On Tue, Dec 16, 2008 at 1:36 AM, 浩翔 <blackange...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > there is have a error. "Attempt to call private method" --- > > > > format > > > > See: <http://wiki.rubyonrails.org/rails/pages/ReservedWords> -- the > > > "reported to cause trouble" section includes ''format''. > > > > You might want to rename that attribute of your model. > > > > HTH, > > > -- > > > Hassan Schroeder ------------------------ hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > > -- > TWRUG Blog:http://blog.rubyonrails.org.tw > > CFC on Rails:http://zusocfc.blogspot.com > > Only two surfaces of a box:http://blog.pixnet.net/zusocfc--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Same as the model Change @release.format to @release[:format] :) Cause format is a private method, so you can''t call it. No matter it is in the model or in the view. So, you can use model[:method] to grab the correct column. Or, you can try to use: read_attribute("format") in the model :) On Thu, Dec 18, 2008 at 10:11 PM, 浩翔 <blackanger.Z-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Thank you. > I know the issue. sefl[:format] is good. > but i dont'' understand why it reported the error : "Attempt to call > private method" in View page, when i called show action. > > I know the column ''format'' will be cause trouble. beacuse all of > instance variable has the private method named ''format'', right ? > > but why it is good as following : > -------------------------------------------------- > app/views/release/show.html.erb > -------------------------------------------------- > <p> > <b>Movie:</b> > <%=h @release.movie_id %> > </p> > > <p> > <b>Format:</b> > <%=h @release.format %> > </p> > > <p> > <b>Released on:</b> > <%=h @release.released_on %> > </p> > > <%= link_to ''Edit'', edit_release_path(@release) %> | > <%= link_to ''Back'', releases_path %> > > it is good . but when i changed <%=h @release.movie_id %> to < > %=h @release.movie.title %>, when i called show action , it > reported a error :"Attempt to call private method"( this line: <%=h > @release.format %>) > > > > how can to explain it ? thank you. > > > > > > > > > > > > > > > On Dec 17, 6:52 pm, CFC <zuso...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Did you mean: You got the error in the Model, but it was worked in the > View? > > > > Maybe you can try this in the Model: > > > > self[:format] replace self.format > > > > > > > > On Wed, Dec 17, 2008 at 5:34 PM, 浩翔 <blackange...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Thank you. > > > > > I know the ''format'' cause trouble, it''s a private method , cause > > > stop calling method_missing, > > > I change ''format'' to ''formater'' or other form, it''s be fine. > > > > > but why this is good : > > > -------------------------------------------------- > > > app/views/release/show.html.erb > > > -------------------------------------------------- > > > <p> > > > <b>Movie:</b> > > > <%=h @release.movie_id %> > > > </p> > > > > > <p> > > > <b>Format:</b> > > > <%=h @release.format %> > > > </p> > > > > > <p> > > > <b>Released on:</b> > > > <%=h @release.released_on %> > > > </p> > > > > > <%= link_to ''Edit'', edit_release_path(@release) %> | > > > <%= link_to ''Back'', releases_path %> > > > > > Could u help me understand it ? > > > > > On Dec 16, 8:52 pm, "Hassan Schroeder" <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > > wrote: > > > > On Tue, Dec 16, 2008 at 1:36 AM, 浩翔 <blackange...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > there is have a error. "Attempt to call private method" --- > > > > > format > > > > > > See: <http://wiki.rubyonrails.org/rails/pages/ReservedWords> -- the > > > > "reported to cause trouble" section includes ''format''. > > > > > > You might want to rename that attribute of your model. > > > > > > HTH, > > > > -- > > > > Hassan Schroeder ------------------------ hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > > > > -- > > TWRUG Blog:http://blog.rubyonrails.org.tw > > > > CFC on Rails:http://zusocfc.blogspot.com > > > > Only two surfaces of a box:http://blog.pixnet.net/zusocfc > > >-- TWRUG Blog: http://blog.rubyonrails.org.tw CFC on Rails: http://zusocfc.blogspot.com Only two surfaces of a box: http://blog.pixnet.net/zusocfc --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi,Am Almas M totally new to this site i was jst going the site of Ruby''s on Rails i hav no idea how am i to begin with.It would be really gud if u guide and let me wht is it all about. Rdgs Almas --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
why i can call format in this page: -------------------------------------------------- app/views/release/show.html.erb -------------------------------------------------- <p> <b>Movie:</b> <%=h @release.movie_id %> </p> <p> <b>Format:</b> <%=h @release.format %> </p> <p> <b>Released on:</b> <%=h @release.released_on %> </p> <%= link_to ''Edit'', edit_release_path(@release) %> | <%= link_to ''Back'', releases_path %> it is good! format can be call . why ? I''m really confused! On Dec 18, 11:22 pm, CFC <zuso...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Same as the model > Change @release.format to @release[:format] > :) > Cause format is a private method, so you can''t call it. > No matter it is in the model or in the view. > So, you can use model[:method] to grab the correct column. > Or, you can try to use: read_attribute("format") in the model :) > > > > On Thu, Dec 18, 2008 at 10:11 PM, 浩翔 <blackange...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Thank you. > > I know the issue. sefl[:format] is good. > > but i dont'' understand why it reported the error : "Attempt to call > > private method" in View page, when i called show action. > > > I know the column ''format'' will be cause trouble. beacuse all of > > instance variable has the private method named ''format'', right ? > > > but why it is good as following : > > -------------------------------------------------- > > app/views/release/show.html.erb > > -------------------------------------------------- > > <p> > > <b>Movie:</b> > > <%=h @release.movie_id %> > > </p> > > > <p> > > <b>Format:</b> > > <%=h @release.format %> > > </p> > > > <p> > > <b>Released on:</b> > > <%=h @release.released_on %> > > </p> > > > <%= link_to ''Edit'', edit_release_path(@release) %> | > > <%= link_to ''Back'', releases_path %> > > > it is good . but when i changed <%=h @release.movie_id %> to < > > %=h @release.movie.title %>, when i called show action , it > > reported a error :"Attempt to call private method"( this line: <%=h > > @release.format %>) > > > how can to explain it ? thank you. > > > On Dec 17, 6:52 pm, CFC <zuso...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Did you mean: You got the error in the Model, but it was worked in the > > View? > > > > Maybe you can try this in the Model: > > > > self[:format] replace self.format > > > > On Wed, Dec 17, 2008 at 5:34 PM, 浩翔 <blackange...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Thank you. > > > > > I know the ''format'' cause trouble, it''s a private method , cause > > > > stop calling method_missing, > > > > I change ''format'' to ''formater'' or other form, it''s be fine. > > > > > but why this is good : > > > > -------------------------------------------------- > > > > app/views/release/show.html.erb > > > > -------------------------------------------------- > > > > <p> > > > > <b>Movie:</b> > > > > <%=h @release.movie_id %> > > > > </p> > > > > > <p> > > > > <b>Format:</b> > > > > <%=h @release.format %> > > > > </p> > > > > > <p> > > > > <b>Released on:</b> > > > > <%=h @release.released_on %> > > > > </p> > > > > > <%= link_to ''Edit'', edit_release_path(@release) %> | > > > > <%= link_to ''Back'', releases_path %> > > > > > Could u help me understand it ? > > > > > On Dec 16, 8:52 pm, "Hassan Schroeder" <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > > > wrote: > > > > > On Tue, Dec 16, 2008 at 1:36 AM, 浩翔 <blackange...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > there is have a error. "Attempt to call private method" --- > > > > > > format > > > > > > See: <http://wiki.rubyonrails.org/rails/pages/ReservedWords> -- the > > > > > "reported to cause trouble" section includes ''format''. > > > > > > You might want to rename that attribute of your model. > > > > > > HTH, > > > > > -- > > > > > Hassan Schroeder ------------------------ hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > > > > -- > > > TWRUG Blog:http://blog.rubyonrails.org.tw > > > > CFC on Rails:http://zusocfc.blogspot.com > > > > Only two surfaces of a box:http://blog.pixnet.net/zusocfc > > -- > TWRUG Blog:http://blog.rubyonrails.org.tw > > CFC on Rails:http://zusocfc.blogspot.com > > Only two surfaces of a box:http://blog.pixnet.net/zusocfc--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
you can read <Agile Web Development With Rails 3rdEdition> On Dec 18, 11:46 pm, "almas ali" <brightal...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi,Am Almas M totally new to this site i was jst going the site of Ruby''s on > Rails i hav no idea how am i to begin with.It would be really gud if u guide > and let me wht is it all about. > > Rdgs > Almas--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---