Hi Guillaume,

First thing if you want to modify the title on your product after
getting it with @product = Product.find(params[:id]) you cant do
"Product.title =  "You don't decide the title! I do!"" as "Product"
refers to your class and not to the object. You must refer the object
that way:

@product = Product.find(params[:id]) # Getting the product
@product.title =  "You don't decide the title! I do!" # Updating title
@product.save # Saving object in database

Another thing, if you have a undefined method `title=' for #<Class:
0x365b654> error, it seems that your Product class don't have a title
attribute. Check in the database that your Product table has a title
attribute before trying to update it ^^

Cheers,
Olivier.

On 20 feb, 13:19, Guillaume Loader <[email protected]>
wrote:
> Hello everyone!
>
> I'm trying to modify an example from a book. The example show how to
> create a scaffold for a table.
>
> But I want to change the way things are modified.
>
> Here is the method in my controller :
>
>   def update
>     @product = Product.find(params[:id])
>
>     respond_to do |format|
>       if @product.update_attributes(params[:product])
>         flash[:notice] = 'Product was successfully updated.'
>         format.html { redirect_to(@product) }
>         format.xml  { head :ok }
>       else
>         format.html { render :action => "edit" }
>         format.xml  { render :xml => @product.errors, :status =>
> :unprocessable_entity }
>       end
>     end
>   end
>
> So I tried to add this line :
>
> Product.title =  "You don't decide the title! I do!"
>
> after @product = Product.find(params[:id])
>
> But I got an error (undefined method `title=' for #<Class:0x365b654>)
>
> Could you help me?
>
> Thank you!
> --
> Posted viahttp://www.ruby-forum.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