Thank you!

I did:

post "comprar/:id" => "comprar#add_item"

and seens to work! But everything I put inside the <% form_for @cart, :url 
=> {:action => "add_item", :id => @cart.id} do |f| %>

is not showing in the view. I even look for with element inspector, but the 
form for is not rendering what is inside.



Em quinta-feira, 14 de agosto de 2014 08h15min17s UTC-3, Fernando Aureliano 
escreveu:
>
> Hi guys!
>
> I'm doing a shopping cart with the gem:  gem act_as_shopping_cart (
> https://github.com/crowdint/acts_as_shopping_cart)
>
> This gem do not have a good documentation, butis popular.
>
> in my action add_item I'm getting the error:
>
> No route matches {:action=>"add_item", :id=>nil, :controller=>"comprar"}
>
>
> This is my controller to items:
>
> class ComprarController < SuperSiteController
>   def index
>     @v = Video.order('created_at asc')
>     @n = News.all
>     @cat = Category.all
>   end
>
>   def show
>     @v = Video.find(params[:id])
>     @n = News.all
>     @cat = Category.all
>     @cart = Cart.new
>   end
>
>   def add_item
>     @cart = Cart.create
>     @product = Video.find(params[:id])
>
>     @cart.add(@product, @product.week_price)
>   end
> end
>
>
>
> the model to my cart:
>
> class Cart < ActiveRecord::Base
>     attr_accessible :id, :owner_id, :owner_type, :quantity,
>               :item_id, :item_type, :price
>
>
>     acts_as_shopping_cart_using :video
>   end
>
>
> the model to items to sell:
>  
> class Video < ActiveRecord::Base
>     attr_accessible :active, :desc, :embed, :img1, :img1_uid, 
>             :img2, :img2_uid, :img3, :img3_uid, :img4, 
>             :img4_uid, :infos, :month_price, :slug, :title, 
>             :trailer, :views, :week_price, :year_price, :category_id
>
>
>
>     belongs_to :category
>
>   acts_as_shopping_cart_item_for :cart
> end
>
>
> and the code in my view "show":
>
>
> <% form_for @cart, :url => {:action => "add_item", :id => @cart.id} do 
> |f| %>
>        <%= f.submit 'Add to Cart' %>
> <% end %>
>
>
> Someone is seeing something that I'm not? 
>
>
> I following the documentation, but still get this error
>
>  Add Items
>
> To add an item to the cart you use the add method. You have to send the 
> object and the price of the object as parameters.
>
> So, if you had a Product class, you would do something like this:
>
> @cart = Cart.create
> @product = Product.find(1)
>
> @cart.add(@product, 99.99)
>
>
>
>
> Thanks!
>
>
> -- 
> *Fernando Aureliano*
> fernandoaureliano.com
>
>
>  

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/0d65380e-1113-478b-ad6b-db37364be38d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to