Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8465051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:55:55+00:00 2026-06-10T14:55:55+00:00

I am doing an exercise from a book called Agile Web Development. The mission

  • 0

I am doing an exercise from a book called Agile Web Development. The mission is that:

The users can add product to the cart when they kick the item image.
So I wrap the image tag into an anchor tag. Just like <%= link_to image_tag(product.image_url), line_items_path(:product_id => product), html_options = {:method => :post} %>

It seems to be fine which I kick the image, but it does not add anything into the cart.
I checked out the discussion in book’s website, some of the solutions are similar to my one. But they also don’t works.

Code is going to run when I kick the image:

# POST /line_items
# POST /line_items.json
def create
  # for exercise only
  session[:couter] = nil

  @cart = current_cart
  product = Product.find(params[:product_id])
  @line_item = @cart.line_items.build(:product=>product)

  respond_to do |format|
    if @line_item.save
      format.html { redirect_to @line_item.cart, notice: 'Line item was successfully created.' }
      format.json { render json: @line_item, status: :created, location: @line_item }
    else
      format.html { render action: "new" }
      format.json { render json: @line_item.errors, status: :unprocessable_entity }
    end
  end
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T14:55:57+00:00Added an answer on June 10, 2026 at 2:55 pm

    I figured out what is going on.
    It is the problem of the book, not the rails.

    The original <%= javascript_tag 'application %>'

    The book taught me change it to<%= javascript_include_tag :default %>

    So I cannot import the javascript Library 🙁

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am doing an exercise from Orielly book, and they used that Twitter package
Today I was doing the thread ring exercise from the Programming Erlang book and
I am doing some exercise from a book and have some problems with the
I am a beginner in Java and am doing an exercise from a book.
doing some exercise from a book I've come across a doubt. I've defined some
noob here. I'm doing an exercise from a book and the compiler reports no
noob here. Having a doubt while doing an exercise from a book. The doubt
I'm doing the exercise sudoku from the book hello to android. I saw some
I was doing an exercise on F# Wiki Book on List (scroll to the
Hey all. I'm doing a linked list exercise that involves dynamic memory allocation, pointers,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.