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

Have you tried?

def index
@object = Object.new
@object.name = ‘default value’

end



John B.

Sure, but got error:

undefined method `name=’ for #Object:0x333c1a0

with
def index
@sometest = Object.new
@sometest.name = ‘testname’
end

/tom

John B. wrote:

and would like to do something like this from controller
PS: now using <%= text_field_tag “object_name”, @object_value %> and

Rails mailing list
[email protected]
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

and you’ve done attr_accessor :name or some equivalent in the class
definition?



John B.