I am using rails 3 and the steps that I have done

1.rails new MeBay

2.rails g model ad name:string description:text price:decimal
seller_id:integer email:string imr_url:string

3.rake db:migrate

4.rails generate controller ads

5.show.html.erb


<html>
     <head>
       <title> </title>
     </head>
     <body>
     <p>
       <b>Name:</b><%= @ad.name %>
     </p>
     <p>
      <b>Description:</b><%= @ad.description %>
     </p>
     <p>
      <b>Price:</b><%= @ad.price %>
     </p>
     <p>
      <b>Seller Id:</b><%= @ad.seller_id %>
     </p>
     <p>
      <b>Email:</b><%= @ad.email %>
     </p>
     <p>
      <img src="<%= @ad.img_url %>"/>
     </p>
     </body>
     </html>


6.config/routes.rb

controller 'ads' do
                match 'ads/:id' => :show
  match 'ads/:id' => :index
        end


7.ads_controller
def show
   @ad = Ad.find(params[:id])
end
def index
   @ads = Ad.find(:all)
end




8. index.html.erb
<h1>All ads</h1>
<ul>
   <% for ad in @ads %>
   <li><a href ="/ads/<%= ad.id %>"><%= ad.name %></a></li>
   <% end %>
</ul>


after starting the rails server

in browser I am trying

http://localhost:3000/MeBay
http://localhost:3000/show/ads/3

I am getting routing error. Please help on solving this error.

No route matches [GET] "/MeBay"
No route matches [GET] "/show/ads/3"

please note:other scaffolding project that I created in RoR runs well. but
not this one. please help where I went wrong.

--
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+unsubscribe@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/3d24aeb4-c5d2-4ed0-a79d-b8aa079b01c7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Priya Mohan at Sep 4, 2015 at 5:23 am
    I am using rails 3 and the steps that I have done

    1.rails new MeBay

    2.rails g model ad name:string description:text price:decimal
    seller_id:integer email:string imr_url:string

    3.rake db:migrate

    4.rails generate controller ads

    5.show.html.erb

      <html>
         <head>
           <title> </title>
         </head>
         <body>
         <p>
           <b>Name:</b><%= @ad.name %>
         </p>
         <p>
          <b>Description:</b><%= @ad.description %>
         </p>
         <p>
          <b>Price:</b><%= @ad.price %>
         </p>
         <p>
          <b>Seller Id:</b><%= @ad.seller_id %>
         </p>
         <p>
          <b>Email:</b><%= @ad.email %>
         </p>
         <p>
          <img src="<%= @ad.img_url %>"/>
         </p>
         </body>
         </html>



    6.config/routes.rb

    controller 'ads' do
                    match 'ads/:id' => :show
      match 'ads/:id' => :index
            end



    7.ads_controller
    def show
       @ad = Ad.find(params[:id])
    end
    def index
       @ads = Ad.find(:all)
    end



    8. index.html.erb
    <h1>All ads</h1>
    <ul>
       <% for ad in @ads %>
       <li><a href ="/ads/<%= ad.id %>"><%= ad.name %></a></li>
       <% end %>
    </ul>



    after starting the rails server

    in browser I am trying

    http://localhost:3000/MeBay
    http://localhost:3000/show/ads/3

    I am getting routing error. Please help on solving this error.

    No route matches [GET] "/MeBay"
    No route matches [GET] "/show/ads/3"

    please note:other scaffolding project that I created in RoR runs well. but
    not this one. please help where I went wrong.

    --
    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+unsubscribe@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/5ec07007-5ae6-45bd-ba10-a7e01d4e0c60%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Colin Law at Sep 4, 2015 at 6:22 am

    On 3 September 2015 at 21:56, Priya Mohan wrote:
    I am using rails 3 and the steps that I have done

    1.rails new MeBay

    2.rails g model ad name:string description:text price:decimal
    seller_id:integer email:string imr_url:string

    3.rake db:migrate

    4.rails generate controller ads

    5.show.html.erb


    <html>
    <head>
    <title> </title>
    </head>
    <body>
    <p>
    <b>Name:</b><%= @ad.name %>
    </p>
    <p>
    <b>Description:</b><%= @ad.description %>
    </p>
    <p>
    <b>Price:</b><%= @ad.price %>
    </p>
    <p>
    <b>Seller Id:</b><%= @ad.seller_id %>
    </p>
    <p>
    <b>Email:</b><%= @ad.email %>
    </p>
    <p>
    <img src="<%= @ad.img_url %>"/>
    </p>
    </body>
    </html>


    6.config/routes.rb

    controller 'ads' do
    match 'ads/:id' => :show
    match 'ads/:id' => :index
    end


    7.ads_controller
    def show
    @ad = Ad.find(params[:id])
    end
    def index
    @ads = Ad.find(:all)
    end




    8. index.html.erb
    <h1>All ads</h1>
    <ul>
    <% for ad in @ads %>
    <li><a href ="/ads/<%= ad.id %>"><%= ad.name %></a></li>
    <% end %>
    </ul>


    after starting the rails server

    in browser I am trying

    http://localhost:3000/MeBay
    http://localhost:3000/show/ads/3

    I am getting routing error. Please help on solving this error.

    No route matches [GET] "/MeBay"
    No route matches [GET] "/show/ads/3"

    please note:other scaffolding project that I created in RoR runs well. but
    not this one. please help where I went wrong.
    Firstly don't use Rails 3 as it is not only obsolete but will go out
    of support within a few months. As a beginner I suggest you work
    right through a good tutorial (which uses the latest rails) such as
    railstutorial.org (which is free to use online). That will show you
    the basics or Rails.

    As for your specific problem it should be /ads/show/3. Also the route
    for index should not include the id. But in routes.rb you should be
    using resources rather than match for such cases. As I said work
    through the tutorial before going further.

    Colin

    --
    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+unsubscribe@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/CAL%3D0gLs10W9fqCRq%3D3ON3UYsBDX0d66-CLH%3D0oz3t3WEWAYzmA%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.
  • Tamouse pontiki at Sep 6, 2015 at 2:00 pm

    On Fri, Sep 4, 2015 at 1:21 AM, Colin Law wrote:
    On 3 September 2015 at 21:56, Priya Mohan wrote:
    6.config/routes.rb

    controller 'ads' do
    match 'ads/:id' => :show
    match 'ads/:id' => :index
    end
    As for your specific problem it should be /ads/show/3. Also the route
    for index should not include the id. But in routes.rb you should be
    using resources rather than match for such cases.

    The "show" route would just be /ads/3 : http://localhost:3000/ads/3
    The "index" route is just /ads: http://localhost:3000/ads

    As I said work
    through the tutorial before going further.

    Colin

    Tamara

    --
    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+unsubscribe@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/CAHUC_t_Bw%2B5-r6HYFCnfgiFxTyB9dKy%3DyShSEUfm%3DdDihgs%3D%3DQ%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.
  • Colin Law at Sep 7, 2015 at 7:40 pm

    On 6 September 2015 at 15:00, tamouse pontiki wrote:
    On Fri, Sep 4, 2015 at 1:21 AM, Colin Law wrote:
    On 3 September 2015 at 21:56, Priya Mohan wrote:
    6.config/routes.rb

    controller 'ads' do
    match 'ads/:id' => :show
    match 'ads/:id' => :index
    end
    As for your specific problem it should be /ads/show/3. Also the route
    for index should not include the id. But in routes.rb you should be
    using resources rather than match for such cases.

    The "show" route would just be /ads/3 : http://localhost:3000/ads/3
    That's true, perhaps I need to work through the tutorial again myself :)

    Colin

    --
    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+unsubscribe@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/CAL%3D0gLvgj9QtCWcN59LccV8BC_7jQJeSuMBup_2pDmNFLvy_5g%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.
  • Tamouse pontiki at Sep 9, 2015 at 3:15 am

    On Mon, Sep 7, 2015 at 2:40 PM, Colin Law wrote:
    On 6 September 2015 at 15:00, tamouse pontiki wrote:
    On Fri, Sep 4, 2015 at 1:21 AM, Colin Law wrote:
    On 3 September 2015 at 21:56, Priya Mohan wrote:
    6.config/routes.rb

    controller 'ads' do
    match 'ads/:id' => :show
    match 'ads/:id' => :index
    end
    As for your specific problem it should be /ads/show/3. Also the route
    for index should not include the id. But in routes.rb you should be
    using resources rather than match for such cases.

    The "show" route would just be /ads/3 : http://localhost:3000/ads/3
    That's true, perhaps I need to work through the tutorial again myself :)
    I have the guides, the api docs, and Ruby's Enumerable pinned in my browser
    for re-reading. :)

    --
    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+unsubscribe@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/CAHUC_t_LTN0DvEgvgNey9F3cLkJoWPQB5_D7xzh7iDZ%2B1M%3DM%2BQ%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedSep 4, '15 at 5:23a
activeSep 9, '15 at 3:15a
posts6
users3
websiterubyonrails.org
irc#RubyOnRails

People

Translate

site design / logo © 2021 Grokbase