use
@car = Car.create( :name => params[:car])  ,

or
@car = Car.find_or_create_by_name(params[:car])
if you don't want duplicate items.

On Tue, Dec 1, 2009 at 3:34 AM, charlene cassar <[email protected]>wrote:

> I didn't add the routing properly :S
>
>
> Now that i'm in my car controller, I want to call a view in the user views.
> How do i go from the controller to the view???
>
>
> Thanks
>
> 2009/11/30 [email protected] <[email protected]>
>
> cell.name ? cell is the object, so .to_s method is going to print out
>> the object summary
>>
>> On Nov 29, 10:26 pm, Me <[email protected]> wrote:
>> > What is not working?
>> >
>> > On Nov 29, 3:40 pm, Char <[email protected]> wrote:
>> >
>> >
>> >
>> > > Hello
>> >
>> > > I have the following situation
>> > > This is my controller:
>> >
>> > > def addcar    @car = Car.new(params[:car])              render :action
>> > > => "list"  endthis is my view: <%(@allcars).each do |cell|%>
>> >
>> > > <%= link_to cell.to_s, :controller => "car", :action => "addcar", :car
>> > > => cell.to_s %>
>> >
>> > > <%end %>
>> >
>> > > In the link_to statement I want to pass cell.to_s to the controller.
>> > > how can i do that please? THe cell.to_s is just a string but I want it
>> > > to be the name of the car object (car.Name)
>> >
>> > > In other words I want to pass "Honda" to the controller so that I can
>> > > save this to the cars table
>> > > Id                                        Name
>> > > (Autogenerated)                   Honda
>> > > (Autogenerated)                   Mercedes
>> >
>> > > etc
>>
>> --
>>
>> 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 [email protected].
>> To unsubscribe from this group, send email to
>> [email protected]<rubyonrails-talk%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/rubyonrails-talk?hl=en.
>>
>>
>>
>  --
> 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 [email protected].
> To unsubscribe from this group, send email to
> [email protected]<rubyonrails-talk%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>



-- 
Liu Lantao
College of Information Science and Technology, Beijing Normal University
EMAIL: liulantao ( at ) gmail ( dot ) com ;
WEBSITE: http://www.liulantao.com/ .
------

--

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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.


Reply via email to