osdir.com
mailing list archive

Subject: [Rails] Re: Form not working... - msg#03259

List: RubyonRailsTalk

Date: Prev Next Index Thread: Prev Next Index

Rob, I still get the same error...

NoMethodError in Sfiles#new

Showing app/views/sfiles/new.html.erb where line #8 raised:

undefined method `merge' for :title:Symbol

Extracted source (around line #8):

5:
6: <p>
7: <%= f.label :title %><br />
8: <%= f.text_field :sfile, :title %>
9: </p>
10: <p>
11: <%= f.label :description %><br />


On 31 jul, 12:04, Rob Biedenharn <R...@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> On Jul 31, 2009, at 10:59 AM, Craig White wrote:
>
>
>
> > On Fri, 2009-07-31 at 07:46 -0700, Gabriel Bianconi wrote:
> >> Hello. I created a form and it always throw the 'Title can't be  
> >> blank'
> >> error, even if I filled it.
>
> >> What is wrong?
>
> >> Thanks,
>
> >> Gabriel.
>
> >> ----------------------------
>
> >> # new.html.erb
> >> <h1>Welcome</h1>
>
> >> <% form_for(@sfile) do |f| %>
> >>  <%= f.error_messages %>
>
> >>  <p>
> >>    <%= f.label :title %><br />
> >>    <%= f.text_field :title %>
> >>  </p>
> >>  <p>
> >>    <%= f.label :description %><br />
> >>    <%= f.text_area :description %>
> >>  </p>
> >>  <p>
> >>    <%= f.submit 'Create' %>
> >>  </p>
> >> <% end %>
>
> >> ----
>
> >> # sfile.rb
> >> class Sfile < ActiveRecord::Base
> >>         validates_presence_of :title
> >> end
>
> >> ---
>
> >> # sfiles_controller.rb
> >> class SfilesController < ApplicationController
> >>         def new
> >>                 @sfile = Sfile.new
> >>         end
>
> >>         def create
> >>                 @sfile = Sfile.new(params[:product])
>
> You didn't fix :product on this line to be :sfile.  Take a look at the  
> source that your form has generated and you should see the title field  
> has a name like:  "sfile[title]"
>
>
>
> >>                 respond_to do |format|
> >>                         if @sfile.save
> >>                                 flash[:notice] = 'File was successfully
> >> created.'
> >>                                 format.html { redirect_to(@sfile) }
> >>                         else
> >>                                 format.html { render :action => "new" }
> >>                         end
> >>                 end
> >>         end
>
> >>         def show
> >>                 @sfile = Sfile.find(params[:id])
> >>         end
> >> end
> > ----
> > try...
>
> > <% form_for(@sfile) do |f| %>
> >  <%= f.error_messages %>
>
> >  <p>
> >    <%= f.label :title %><br />
> >    <%= f.text_field :product, :title %>
> >  </p>
> >  <p>
> >    <%= f.label :description %><br />
> >    <%= f.text_area :product, :description %>
> >  </p>
> >  <p>
> >    <%= f.submit 'Create' %>
> >  </p>
> > <% end %>
>
> > Craig
>
> > --
> > This message has been scanned for viruses and
> > dangerous content by MailScanner, and is
> > believed to be clean.
>
> Rob Biedenharn          http://agileconsultingllc.com
> R...@xxxxxxxxxxxxxxxxxxxxxx
> +1 513-295-4739
> Skype:  rob.biedenharn
--~--~---------~--~----~------------~-------~--~----~
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@xxxxxxxxxxxxxxxx
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@xxxxxxxxxxxxxxxx
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

[Rails] Re: Form not working...

2009/7/31 Craig White <craigwhite@xxxxxxxxxxx>: > > On Fri, 2009-07-31 at 07:46 -0700, Gabriel Bianconi wrote: >> Hello. I created a form and it always throw the 'Title can't be blank' >> error, even if I filled it. >> >> What is wrong? >> >> Thanks, >> >> Gabriel. >> >> ---------------------------- >> >> # new.html.erb >> <h1>Welcome</h1> >> >> <% form_for(@sfile) do |f| %> >> Â <%= f.error_messages %> >> >> Â <p> >> Â Â <%= f.label :title %><br /> >> Â Â <%= f.text_field :title %> >> Â </p> >> Â <p> >> Â Â <%= f.label :description %><br /> >> Â Â <%= f.text_area :description %> >> Â </p> >> Â <p> >> Â Â <%= f.submit 'Create' %> >> Â </p> >> <% end %> >> >> ---- >> >> # sfile.rb >> class Sfile < ActiveRecord::Base >> Â Â Â Âvalidates_presence_of :title >> end >> >> >> --- >> >> # sfiles_controller.rb >> class SfilesController < ApplicationController >> Â Â Â Âdef new >> Â Â Â Â Â Â Â Â@sfile = Sfile.new >> Â Â Â Âend >> >> Â Â Â Âdef create >> Â Â Â Â Â Â Â Â@sfile = Sfile.new(params[:product]) Should this be params[:sfile]? I am not sure where product comes in. Have a look in the log file (log/development.log) to see what parameters are being posted. >> Â Â Â Â Â Â Â Ârespond_to do |format| >> Â Â Â Â Â Â Â Â Â Â Â Âif @sfile.save >> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âflash[:notice] = 'File was successfully >> created.' >> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âformat.html { redirect_to(@sfile) } >> Â Â Â Â Â Â Â Â Â Â Â Âelse >> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âformat.html { render :action => "new" } >> Â Â Â Â Â Â Â Â Â Â Â Âend >> Â Â Â Â Â Â Â Âend >> Â Â Â Âend >> >> Â Â Â Âdef show >> Â Â Â Â Â Â Â Â@sfile = Sfile.find(params[:id]) >> Â Â Â Âend >> end > ---- > try... > > <% form_for(@sfile) do |f| %> > Â<%= f.error_messages %> > > Â<p> > Â Â<%= f.label :title %><br /> > Â Â<%= f.text_field :product, :title %> I think the OP had this bit correct as it is f.text_field not just text_field Colin > Â</p> > Â<p> > Â Â<%= f.label :description %><br /> > Â Â<%= f.text_area :product, :description %> > Â</p> > Â<p> > Â Â<%= f.submit 'Create' %> > Â</p> > <% end %> > --~--~---------~--~----~------------~-------~--~----~ 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@xxxxxxxxxxxxxxxx To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@xxxxxxxxxxxxxxxx For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

Next Message by Date: click to view message preview

[Rails] Re: Form not working...

Changing back to my original code, i get this in the log: [4;36;1mSQL (0.0ms) [0m [0;1mSET NAMES 'utf8' [0m [4;35;1mSQL (0.0ms) [0m [0mSET SQL_AUTO_IS_NULL=0 [0m Processing SfilesController#create (for 127.0.0.1 at 2009-07-31 12:12:26) [POST] Parameters: {"commit"=>"Create", "authenticity_token"=>"cS/ xZND8RchwVPTwbGcE7HJe5ZndhyutqCVycX20vBQ=", "sfile"=>{"title"=>"Test Title", "description"=>""}} [4;36;1mSfile Columns (0.0ms) [0m [0;1mSHOW FIELDS FROM `sfiles` [0m [4;35;1mSQL (0.0ms) [0m [0mBEGIN [0m [4;36;1mSQL (0.0ms) [0m [0;1mROLLBACK [0m Rendering sfiles/new Completed in 15ms (View: 0, DB: 0) | 200 OK [http://localhost/sfiles] [4;35;1mSQL (0.0ms) [0m [0mSET NAMES 'utf8' [0m [4;36;1mSQL (0.0ms) [0m [0;1mSET SQL_AUTO_IS_NULL=0 [0m Processing SfilesController#create (for 127.0.0.1 at 2009-07-31 12:12:31) [POST] Parameters: {"commit"=>"Create", "authenticity_token"=>"cS/ xZND8RchwVPTwbGcE7HJe5ZndhyutqCVycX20vBQ=", "sfile"=>{"title"=>"", "description"=>""}} [4;35;1mSfile Columns (0.0ms) [0m [0mSHOW FIELDS FROM `sfiles` [0m [4;36;1mSQL (0.0ms) [0m [0;1mBEGIN [0m [4;35;1mSQL (0.0ms) [0m [0mROLLBACK [0m Rendering sfiles/new Completed in 15ms (View: 0, DB: 0) | 200 OK [http://localhost/sfiles] On 31 jul, 12:07, Colin Law <clan...@xxxxxxxxxxxxxx> wrote: > 2009/7/31 Craig White <craigwh...@xxxxxxxxxxx>: > > > > > > > On Fri, 2009-07-31 at 07:46 -0700, Gabriel Bianconi wrote: > >> Hello. I created a form and it always throw the 'Title can't be blank' > >> error, even if I filled it. > > >> What is wrong? > > >> Thanks, > > >> Gabriel. > > >> ---------------------------- > > >> # new.html.erb > >> <h1>Welcome</h1> > > >> <% form_for(@sfile) do |f| %> > >>   <%= f.error_messages %> > > >>   <p> > >>     <%= f.label :title %><br /> > >>     <%= f.text_field :title %> > >>   </p> > >>   <p> > >>     <%= f.label :description %><br /> > >>     <%= f.text_area :description %> > >>   </p> > >>   <p> > >>     <%= f.submit 'Create' %> > >>   </p> > >> <% end %> > > >> ---- > > >> # sfile.rb > >> class Sfile < ActiveRecord::Base > >>        validates_presence_of :title > >> end > > >> --- > > >> # sfiles_controller.rb > >> class SfilesController < ApplicationController > >>        def new > >>                @sfile = Sfile.new > >>        end > > >>        def create > >>                @sfile = Sfile.new(params[:product]) > > Should this be params[:sfile]?  I am not sure where product comes in. > Have a look in the log file (log/development.log) to see what > parameters are being posted. > > > > >>                respond_to do |format| > >>                        if @sfile.save > >>                                flash[:notice] = 'File was successfully > >> created.' > >>                                format.html { redirect_to(@sfile) } > >>                        else > >>                                format.html { render :action => "new" } > >>                        end > >>                end > >>        end > > >>        def show > >>                @sfile = Sfile.find(params[:id]) > >>        end > >> end > > ---- > > try... > > > <% form_for(@sfile) do |f| %> > >  <%= f.error_messages %> > > >  <p> > >    <%= f.label :title %><br /> > >    <%= f.text_field :product, :title %> > > I think the OP had this bit correct as it is f.text_field not just text_field > > Colin > > >  </p> > >  <p> > >    <%= f.label :description %><br /> > >    <%= f.text_area :product, :description %> > >  </p> > >  <p> > >    <%= f.submit 'Create' %> > >  </p> > > <% end %> --~--~---------~--~----~------------~-------~--~----~ 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@xxxxxxxxxxxxxxxx To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@xxxxxxxxxxxxxxxx For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

Previous Message by Thread: click to view message preview

[Rails] Re: Form not working...

On Jul 31, 2009, at 10:59 AM, Craig White wrote: > On Fri, 2009-07-31 at 07:46 -0700, Gabriel Bianconi wrote: >> Hello. I created a form and it always throw the 'Title can't be >> blank' >> error, even if I filled it. >> >> What is wrong? >> >> Thanks, >> >> Gabriel. >> >> ---------------------------- >> >> # new.html.erb >> <h1>Welcome</h1> >> >> <% form_for(@sfile) do |f| %> >> <%= f.error_messages %> >> >> <p> >> <%= f.label :title %><br /> >> <%= f.text_field :title %> >> </p> >> <p> >> <%= f.label :description %><br /> >> <%= f.text_area :description %> >> </p> >> <p> >> <%= f.submit 'Create' %> >> </p> >> <% end %> >> >> ---- >> >> # sfile.rb >> class Sfile < ActiveRecord::Base >> validates_presence_of :title >> end >> >> >> --- >> >> # sfiles_controller.rb >> class SfilesController < ApplicationController >> def new >> @sfile = Sfile.new >> end >> >> def create >> @sfile = Sfile.new(params[:product]) You didn't fix :product on this line to be :sfile. Take a look at the source that your form has generated and you should see the title field has a name like: "sfile[title]" >> respond_to do |format| >> if @sfile.save >> flash[:notice] = 'File was successfully >> created.' >> format.html { redirect_to(@sfile) } >> else >> format.html { render :action => "new" } >> end >> end >> end >> >> def show >> @sfile = Sfile.find(params[:id]) >> end >> end > ---- > try... > > <% form_for(@sfile) do |f| %> > <%= f.error_messages %> > > <p> > <%= f.label :title %><br /> > <%= f.text_field :product, :title %> > </p> > <p> > <%= f.label :description %><br /> > <%= f.text_area :product, :description %> > </p> > <p> > <%= f.submit 'Create' %> > </p> > <% end %> > > Craig > > > -- > This message has been scanned for viruses and > dangerous content by MailScanner, and is > believed to be clean. > > > > Rob Biedenharn http://agileconsultingllc.com Rob@xxxxxxxxxxxxxxxxxxxxxx +1 513-295-4739 Skype: rob.biedenharn --~--~---------~--~----~------------~-------~--~----~ 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@xxxxxxxxxxxxxxxx To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@xxxxxxxxxxxxxxxx For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

Next Message by Thread: click to view message preview

[Rails] Re: Form not working...

It doesn't work... I get this: NoMethodError in Sfiles#new Showing app/views/sfiles/new.html.erb where line #8 raised: undefined method `merge' for :title:Symbol Extracted source (around line #8): 5: 6: <p> 7: <%= f.label :title %><br /> 8: <%= f.text_field :product, :title %> 9: </p> 10: <p> 11: <%= f.label :description %><br /> On 31 jul, 11:59, Craig White <craigwh...@xxxxxxxxxxx> wrote: > On Fri, 2009-07-31 at 07:46 -0700, Gabriel Bianconi wrote: > > Hello. I created a form and it always throw the 'Title can't be blank' > > error, even if I filled it. > > > What is wrong? > > > Thanks, > > > Gabriel. > > > ---------------------------- > > > # new.html.erb > > <h1>Welcome</h1> > > > <% form_for(@sfile) do |f| %> > >   <%= f.error_messages %> > > >   <p> > >     <%= f.label :title %><br /> > >     <%= f.text_field :title %> > >   </p> > >   <p> > >     <%= f.label :description %><br /> > >     <%= f.text_area :description %> > >   </p> > >   <p> > >     <%= f.submit 'Create' %> > >   </p> > > <% end %> > > > ---- > > > # sfile.rb > > class Sfile < ActiveRecord::Base > >     validates_presence_of :title > > end > > > --- > > > # sfiles_controller.rb > > class SfilesController < ApplicationController > >     def new > >             @sfile = Sfile.new > >     end > > >     def create > >             @sfile = Sfile.new(params[:product]) > >             respond_to do |format| > >                     if @sfile.save > >                             flash[:notice] = 'File was successfully > > created.' > >                             format.html { redirect_to(@sfile) } > >                     else > >                             format.html { render :action => "new" } > >                     end > >             end > >     end > > >     def show > >             @sfile = Sfile.find(params[:id]) > >     end > > end > > ---- > try... > > <% form_for(@sfile) do |f| %> >   <%= f.error_messages %> > >   <p> >     <%= f.label :title %><br /> >     <%= f.text_field :product, :title %> >   </p> >   <p> >     <%= f.label :description %><br /> >     <%= f.text_area :product, :description %> >   </p> >   <p> >     <%= f.submit 'Create' %> >   </p> > <% end %> > > Craig > > -- > This message has been scanned for viruses and > dangerous content by MailScanner, and is > believed to be clean. --~--~---------~--~----~------------~-------~--~----~ 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@xxxxxxxxxxxxxxxx To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@xxxxxxxxxxxxxxxx For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Sign up for updates to this mailing list. email:
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by