0

first i listed all the menu that the guest added inside the package that he also added i listed them with this

_menuadded.html.erb

<h1>menu you added</h1>
<% @reservation_package.package_line_items.each do |menu|%> 
<p><%= link_to menu.menu.name, menu_reservation_reservation_package_reservation_package_pages_path(@reservation,@reservation_package,menu) %></p>
<p><%= link_to "delete item" ,reservation_package_package_line_item_path(@reservation_package,menu), :method => :delete%></p>
<%end%>

then i try to route to the next static page with this <p><%= link_to menu.menu.name, menu_reservation_reservation_package_reservation_package_pages_path(@reservation,@reservation_package,menu) %></p>

and the it produce this URL http://localhost:3000/reservations/10/reservation_packages/39/reservation_package_pages/menu.29

im just wondering if how can i catch the menu that he opened i mean how to catch this localhost:3000/reservations/10/reservation_packages/39/reservation_package_pages/menu.29

in my menu semi static page controller where this route to,i tried this

@reservation_package = ReservationPackage.find(params[:reservation_package_id])
@menu = Menu.find(params[:id])

but didn't work at all im just wondering if im doing it right or if im wrong can you give me a advice how to implement this kind of module? thanks more power

ROUTES:

resources :services

   resources :reservations do

     resources :pages do
        collection do
          get :functionroomlist
          get :packagelist
          get :package
        #  get :menu
        end
     end
        resources :reservation_packages do
          resources :reservation_package_pages do
            collection do
               get :menulist 
               get :menu
            end
          end
        resources :package_line_items
        end
     resources :reservation_function_rooms        
    end
Led
  • 615
  • 6
  • 23

1 Answers1

0

We had an similar issue I hope i can help you a little bit my user can create an productlist and he can directly add new products on it. On the show-form i set an link like this

<%= link_to 'Create', new_product_path(:procuctlist => @productlist.id) %>

In the controller of products i definded the new-Action so

def new
    @product_entry = ProductEntry.new
    @product_entry.productlist_id = params[:productlist]

    respond_to do |format|
      format.html # new.html.erb
      format.json { render json: @wishlist_entry }
    end
  end

The Models are defined so

class Product < ActiveRecord::Base

  belongs_to :productlists
  has_many :registrations, :dependent => :destroy
  validates :entry_name, :description, :presence => true

end
class Productlist < ActiveRecord::Base

  has_many :products, :dependent => :destroy

end

the table products contains the field productlist_id. The view of products in our first alpha version contains the productlist_id.

<div class="field">
    <%= f.label :productlist_id %><br />
    <%= f.number_field :productlist_id %>
  </div>

We hope we could help you.

amarradi
  • 109
  • 3
  • 16
  • how can you access your productlist? example if you want to check the productlist_id=1 of product=2? – Led Apr 01 '12 at 12:02
  • Hey @joelparkerhenderson That is really not an usecase in our app, ok we are still in version zero.zero but i would do this over the index-action from productlist. the product in our app is an child of the productlist. Productlist has many Products. If you want do check the productlist_id=1 of product=2 you have to go to product=2 and then over the productlist index action and find the id=1. That the way i would take. Maybe this could help you. `link_to_if` Sorry that i can answer your question and help you. If you find out how it works, would you post it here, it helps – amarradi Apr 01 '12 at 13:24
  • still working on it im new in application development btw how about you? – Led Apr 01 '12 at 13:48
  • thats offtopic:-) thats no chatforum! But i'm working with ruby on rails for six mo... If you look at my profile you will whats my problem today and last weeks is... http://stackoverflow.com/questions/9956975/capistrano-deploycold-doesnt-his-work/9963426#9963426 – amarradi Apr 01 '12 at 14:30