Tom Z Meinlschmidt
2006-Aug-18 09:23 UTC
[Rails] setting a value of text_field from a controller
Hi, I need to set up an initial value from controller. In my views I''ve something like <%= text_field "object", "name" %> and would like to do something like this from controller def index @object[:name] = ''default value'' end but still got an error. Object doesn''t have database model (and will not have) Thank you PS: now using <%= text_field_tag "object_name", @object_value %> and setting in as @object_value = ''something'', but is not so elegant... -- ==============================================================================Tomas Meinlschmidt, SBN3, MCT, MCP, MCP+I, MCSE, NetApp Filer & NetCache gPG: CB78 76D9 210F 256A ADF4 0B02 BECA D462 66AB 6F56 / $ID: 66AB6F56 GCS d-(?) s: a- C++ ULHISC*++++$ P+++>++++ L+++$>++++ E--- W+++$ N++(+) !o !K w(---) !O !M V PS+ PE Y+ PGP++ t+@ !5 X? R tv b+ !DI D+ G e>+++ h---- r+++ z+++@ novy pohled na svicky: http://www.lightgems.cz ===============================================================================
John Browning
2006-Aug-18 09:32 UTC
[Rails] setting a value of text_field from a controller
Have you tried? def index @object = Object.new @object.name = ''default value'' .... end ........................................................................ .......... John Browning On 18 Aug 2006, at 10:23, Tom Z Meinlschmidt wrote:> Hi, > > I need to set up an initial value from controller. In my views I''ve > something like > <%= text_field "object", "name" %> > > and would like to do something like this from controller > > def index > @object[:name] = ''default value'' > end > > but still got an error. Object doesn''t have database model (and > will not have) > > Thank you > > PS: now using <%= text_field_tag "object_name", @object_value %> > and setting in as @object_value = ''something'', but is not so > elegant... > -- > ====================================================================== > ========> Tomas Meinlschmidt, SBN3, MCT, MCP, MCP+I, MCSE, NetApp Filer & > NetCache > gPG: CB78 76D9 210F 256A ADF4 0B02 BECA D462 66AB 6F56 / $ID: 66AB6F56 > GCS d-(?) s: a- C++ ULHISC*++++$ P+++>++++ L+++$>++++ E--- W+++$ N++ > (+) > !o !K w(---) !O !M V PS+ PE Y+ PGP++ t+@ !5 X? R tv b+ !DI D+ G > e>+++ h---- r+++ z+++@ > > novy pohled na svicky: http://www.lightgems.cz > ====================================================================== > ========> _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060818/14bfe7c8/attachment.html
Tom Z Meinlschmidt
2006-Aug-18 10:53 UTC
[Rails] setting a value of text_field from a controller
Sure, but got error: undefined method `name='' for #<Object:0x333c1a0> with def index @sometest = Object.new @sometest.name = ''testname'' end /tom John Browning wrote:> Have you tried? > > def index > @object = Object.new > @object.name = ''default value'' > .... > end > > .................................................................................. > John Browning > > > > On 18 Aug 2006, at 10:23, Tom Z Meinlschmidt wrote: > >> Hi, >> >> I need to set up an initial value from controller. In my views I''ve >> something like >> <%= text_field "object", "name" %> >> >> and would like to do something like this from controller >> >> def index >> @object[:name] = ''default value'' >> end >> >> but still got an error. Object doesn''t have database model (and will >> not have) >> >> Thank you >> >> PS: now using <%= text_field_tag "object_name", @object_value %> and >> setting in as @object_value = ''something'', but is not so elegant... >> -- >> ==============================================================================>> Tomas Meinlschmidt, SBN3, MCT, MCP, MCP+I, MCSE, NetApp Filer & NetCache >> gPG: CB78 76D9 210F 256A ADF4 0B02 BECA D462 66AB 6F56 / $ID: 66AB6F56 >> GCS d-(?) s: a- C++ ULHISC*++++$ P+++>++++ L+++$>++++ E--- W+++$ N++(+) >> !o !K w(---) !O !M V PS+ PE Y+ PGP++ t+@ !5 X? R tv b+ !DI D+ G >> e>+++ h---- r+++ z+++@ >> >> novy pohled na svicky: http://www.lightgems.cz >> ==============================================================================>> _______________________________________________ >> Rails mailing list >> Rails@lists.rubyonrails.org <mailto:Rails@lists.rubyonrails.org> >> http://lists.rubyonrails.org/mailman/listinfo/rails >> > > > ------------------------------------------------------------------------ > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-- ==============================================================================Tomas Meinlschmidt, SBN3, MCT, MCP, MCP+I, MCSE, NetApp Filer & NetCache gPG: CB78 76D9 210F 256A ADF4 0B02 BECA D462 66AB 6F56 / $ID: 66AB6F56 GCS d-(?) s: a- C++ ULHISC*++++$ P+++>++++ L+++$>++++ E--- W+++$ N++(+) !o !K w(---) !O !M V PS+ PE Y+ PGP++ t+@ !5 X? R tv b+ !DI D+ G e>+++ h---- r+++ z+++@ novy pohled na svicky: http://www.lightgems.cz ===============================================================================
John Browning
2006-Aug-18 11:18 UTC
[Rails] setting a value of text_field from a controller
and you''ve done attr_accessor :name or some equivalent in the class definition? ........................................................................ .......... John Browning On 18 Aug 2006, at 11:52, Tom Z Meinlschmidt wrote:> Sure, but got error: > > undefined method `name='' for #<Object:0x333c1a0> > > with > def index > @sometest = Object.new > @sometest.name = ''testname'' > end > > /tom > > John Browning wrote: >> Have you tried? >> def index >> @object = Object.new >> @object.name = ''default value'' >> .... >> end >> ..................................................................... >> ............. >> John Browning >> On 18 Aug 2006, at 10:23, Tom Z Meinlschmidt wrote: >>> Hi, >>> >>> I need to set up an initial value from controller. In my views >>> I''ve something like >>> <%= text_field "object", "name" %> >>> >>> and would like to do something like this from controller >>> >>> def index >>> @object[:name] = ''default value'' >>> end >>> >>> but still got an error. Object doesn''t have database model (and >>> will not have) >>> >>> Thank you >>> >>> PS: now using <%= text_field_tag "object_name", @object_value %> >>> and setting in as @object_value = ''something'', but is not so >>> elegant... >>> -- >>> ==================================================================== >>> ==========>>> Tomas Meinlschmidt, SBN3, MCT, MCP, MCP+I, MCSE, NetApp Filer & >>> NetCache >>> gPG: CB78 76D9 210F 256A ADF4 0B02 BECA D462 66AB 6F56 / $ID: >>> 66AB6F56 >>> GCS d-(?) s: a- C++ ULHISC*++++$ P+++>++++ L+++$>++++ E--- W+++$ N >>> ++(+) >>> !o !K w(---) !O !M V PS+ PE Y+ PGP++ t+@ !5 X? R tv b+ !DI D+ G >>> e>+++ h---- r+++ z+++@ >>> >>> novy pohled na svicky: http://www.lightgems.cz >>> ==================================================================== >>> ==========>>> _______________________________________________ >>> Rails mailing list >>> Rails@lists.rubyonrails.org <mailto:Rails@lists.rubyonrails.org> >>> http://lists.rubyonrails.org/mailman/listinfo/rails >>> >> --------------------------------------------------------------------- >> --- >> _______________________________________________ >> Rails mailing list >> Rails@lists.rubyonrails.org >> http://lists.rubyonrails.org/mailman/listinfo/rails > > > -- > ====================================================================== > ========> Tomas Meinlschmidt, SBN3, MCT, MCP, MCP+I, MCSE, NetApp Filer & > NetCache > gPG: CB78 76D9 210F 256A ADF4 0B02 BECA D462 66AB 6F56 / $ID: 66AB6F56 > GCS d-(?) s: a- C++ ULHISC*++++$ P+++>++++ L+++$>++++ E--- W+++$ N++ > (+) > !o !K w(---) !O !M V PS+ PE Y+ PGP++ t+@ !5 X? R tv b+ !DI D+ G > e>+++ h---- r+++ z+++@ > > novy pohled na svicky: http://www.lightgems.cz > ====================================================================== > ========> _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060818/4dfbbc21/attachment-0001.html