hi im having a bit trouble in my application im new in ROR development i made a static page where my function rooms of my reservation application are showed and can be add in in the reservation_function_room(line item of reservation functionroom) it raises uninitialized constant Reservations cant figure out whats wrong very thanks in advance thanks page-static pages class PagesController < ApplicationController def functionroom @reservation = Reservation.find(params[:reservation_id]) @function_room = FunctionRoom.all end end ------------------------------------------------ functionroom.html.erb <% if notice %> <p id = "notice"><%= notice%></p> <%end%> <h1>functionRooms</h1> <%@function_room.each do |functionroom|%> <h3><%= functionroom.name%></h3> <p><%= number_to_currency(functionroom.price)%></p> <%= button_to ''add function room'', reservation_reservation_function_room_path(:function_room_id => functionroom), :method => :post,:remote => true%> <%end%> ------------------------------------------------- reservation_contoller.rb def index @reservations = Reservation.all end def show @reservation = Reservation.includes(:reservation_function_rooms => :function_room,:reservation_package => :package).find(params[:id]) end ------------------------------------------------- class ReservationFunctionRoomsController < InheritedResources::Base def show @reservation_function_room ReservationFunctionRoom.find(params[:id]) end def new @reservation_function_room = ReservationFunctionRoom.new end def create @reservation = Reservation.find(params[:reservation_id]) function_room = FunctionRoom.find(params[:function_room_id]) @reservation_function_room @reservation.add_function_room(function_room.id) if @reservation_function_room.save redirect_to @reservation, :notice => "function room successfuly added" end end end ------------------------------ routes get "pages/menu" resources :reservation_function_rooms resources :services resources :reservations do get "pages/functionroom" end resources :reservation_packages resources :package_line_items resources :packages do resources :package_crews end resources :function_rooms ------------------------------- reservation.rb class Reservation < ActiveRecord::Base has_one :reservation_package belongs_to :service has_many :reservation_function_rooms has_many :package_line_items has_many :menus , :through => :package_line_items, :uniq => true has_many :function_rooms, :through =>:reservation_function_rooms def add_function_room(function_room_id) current_function_room reservation_function_rooms.find_by_function_room_id(function_room_id) if current_function_room redirect_to @reservation, :notice => "function room already added" else current_function_room reservation_function_rooms.build(:function_room => function_room_id) current_function_room.price current_function_room.function_room.price end current_function_room end end if anything is needed feel free to ask thanks in advance :) -- Posted via http://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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 27 March 2012 10:50, ruby LED <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> hi im having a bit trouble in my application im new in ROR development > i made a static page where my function rooms of my reservation > application are showed and can be add in in the > reservation_function_room(line item of reservation functionroom) it > raises uninitialized constant Reservations cant figure out whats wrong > very thanks in advance thanks > > page-static pages > class PagesController < ApplicationController > > def functionroom > @reservation = Reservation.find(params[:reservation_id]) > @function_room = FunctionRoom.all > end > end > ------------------------------------------------ > > functionroom.html.erb > > <% if notice %> > <p id = "notice"><%= notice%></p> > <%end%> > > <h1>functionRooms</h1> > <%@function_room.each do |functionroom|%> > <h3><%= functionroom.name%></h3> > <p><%= number_to_currency(functionroom.price)%></p> > <%= button_to ''add function room'', > reservation_reservation_function_room_path(:function_room_id => > functionroom), :method => :post,:remote => true%> > <%end%> > > ------------------------------------------------- > reservation_contoller.rb > def index > @reservations = Reservation.all > end > > def show > @reservation = Reservation.includes(:reservation_function_rooms => > :function_room,:reservation_package => :package).find(params[:id]) > end > ------------------------------------------------- > class ReservationFunctionRoomsController < InheritedResources::Base > def show > @reservation_function_room > ReservationFunctionRoom.find(params[:id]) > end > > > def new > @reservation_function_room = ReservationFunctionRoom.new > end > > > def create > @reservation = Reservation.find(params[:reservation_id]) > function_room = FunctionRoom.find(params[:function_room_id]) > @reservation_function_room > @reservation.add_function_room(function_room.id) > > if @reservation_function_room.save > redirect_to @reservation, :notice => "function room successfuly > added" > end > end > end > ------------------------------ > routes > > get "pages/menu" > > resources :reservation_function_rooms > > > > > resources :services > > resources :reservations do > get "pages/functionroom" > end > > resources :reservation_packages > > resources :package_line_items > > > resources :packages do > resources :package_crews > end > > resources :function_rooms > ------------------------------- > reservation.rb > class Reservation < ActiveRecord::Base > has_one :reservation_package > belongs_to :service > has_many :reservation_function_rooms > has_many :package_line_items > has_many :menus , :through => :package_line_items, :uniq => true > has_many :function_rooms, :through =>:reservation_function_rooms > > def add_function_room(function_room_id) > current_function_room > reservation_function_rooms.find_by_function_room_id(function_room_id) > if current_function_room > redirect_to @reservation, :notice => "function room already > added" > else > current_function_room > reservation_function_rooms.build(:function_room => function_room_id) > current_function_room.price > current_function_room.function_room.price > end > current_function_room > end > > end > > if anything is needed feel free to ask thanks in advance :)The most useful thing you could tell us is which line of code generates the error. Also post the full error message and stack trace. Colin -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law wrote in post #1053624:> On 27 March 2012 10:50, ruby LED <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> def functionroom >> <%end%> >> ------------------------------------------------- >> class ReservationFunctionRoomsController < InheritedResources::Base >> >> end >> >> >> has_many :reservation_function_rooms >> else >> if anything is needed feel free to ask thanks in advance :) > The most useful thing you could tell us is which line of code > generates the error. Also post the full error message and stack > trace. > > Colinuhm i cant find the exact code it tells me an error routing when ever i route to uninitialized constant Reservations <%= link_to "add functionrooms", reservation_pages_functionroom_path(@reservation) %> here is my rout -------------------------------- get "pages/menu" resources :services resources :reservations do resources :reservation_function_rooms get ''pages/functionroom'' resources :reservation_packages resources :package_line_items end resources :packages do resources :package_crews end resources :function_rooms resources :crews resources :menu_categories resources :menus do resources :menu_recipes end resources :recipe_categories resources :recipes ------------------------------------ class PagesController < ApplicationController def functionroom @reservation = Reservation.find(params[:reservation_id]) @function_room = FunctionRoom.all end end ------------------------------------ Error stack ActionController::RoutingError (uninitialized constant Reservations): activesupport (3.2.1) lib/active_support/inflector/methods.rb:229:in `block in constantize'' activesupport (3.2.1) lib/active_support/inflector/methods.rb:228:in `each'' activesupport (3.2.1) lib/active_support/inflector/methods.rb:228:in `constantize'' actionpack (3.2.1) lib/action_dispatch/routing/route_set.rb:62:in `controller_reference'' actionpack (3.2.1) lib/action_dispatch/routing/route_set.rb:47:in `controller'' actionpack (3.2.1) lib/action_dispatch/routing/route_set.rb:26:in `call'' journey (1.0.3) lib/journey/router.rb:68:in `block in call'' journey (1.0.3) lib/journey/router.rb:56:in `each'' journey (1.0.3) lib/journey/router.rb:56:in `call'' actionpack (3.2.1) lib/action_dispatch/routing/route_set.rb:589:in `call'' sass (3.1.15) lib/sass/plugin/rack.rb:54:in `call'' warden (1.1.1) lib/warden/manager.rb:35:in `block in call'' warden (1.1.1) lib/warden/manager.rb:34:in `catch'' warden (1.1.1) lib/warden/manager.rb:34:in `call'' actionpack (3.2.1) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'' rack (1.4.1) lib/rack/etag.rb:23:in `call'' rack (1.4.1) lib/rack/conditionalget.rb:25:in `call'' actionpack (3.2.1) lib/action_dispatch/middleware/head.rb:14:in `call'' actionpack (3.2.1) lib/action_dispatch/middleware/params_parser.rb:21:in `call'' actionpack (3.2.1) lib/action_dispatch/middleware/flash.rb:242:in `call'' rack (1.4.1) lib/rack/session/abstract/id.rb:205:in `context'' rack (1.4.1) lib/rack/session/abstract/id.rb:200:in `call'' actionpack (3.2.1) lib/action_dispatch/middleware/cookies.rb:338:in `call'' activerecord (3.2.1) lib/active_record/query_cache.rb:64:in `call'' activerecord (3.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:443:in `call'' actionpack (3.2.1) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'' activesupport (3.2.1) lib/active_support/callbacks.rb:405:in `_run__321294476__call__156324443__callbacks'' activesupport (3.2.1) lib/active_support/callbacks.rb:405:in `__run_callback'' activesupport (3.2.1) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'' activesupport (3.2.1) lib/active_support/callbacks.rb:81:in `run_callbacks'' actionpack (3.2.1) lib/action_dispatch/middleware/callbacks.rb:27:in `call'' actionpack (3.2.1) lib/action_dispatch/middleware/reloader.rb:65:in `call'' actionpack (3.2.1) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'' actionpack (3.2.1) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'' actionpack (3.2.1) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'' railties (3.2.1) lib/rails/rack/logger.rb:26:in `call_app'' railties (3.2.1) lib/rails/rack/logger.rb:16:in `call'' actionpack (3.2.1) lib/action_dispatch/middleware/request_id.rb:22:in `call'' rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'' rack (1.4.1) lib/rack/runtime.rb:17:in `call'' activesupport (3.2.1) lib/active_support/cache/strategy/local_cache.rb:72:in `call'' rack (1.4.1) lib/rack/lock.rb:15:in `call'' actionpack (3.2.1) lib/action_dispatch/middleware/static.rb:53:in `call'' railties (3.2.1) lib/rails/engine.rb:479:in `call'' railties (3.2.1) lib/rails/application.rb:220:in `call'' rack (1.4.1) lib/rack/content_length.rb:14:in `call'' railties (3.2.1) lib/rails/rack/log_tailer.rb:14:in `call'' rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service'' /home/led/.rvm/rubies/ruby-1.9.3-rc1/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'' /home/led/.rvm/rubies/ruby-1.9.3-rc1/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'' /home/led/.rvm/rubies/ruby-1.9.3-rc1/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'' Rendered /home/led/.rvm/gems/ruby-1.9.3-rc1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (1.2ms) just a follow up question is it possible that a semi static object accepts a object thru url paramater like what i did? i suspect my route is not correct thanks mr collin -- Posted via http://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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.