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 %>
<%= notice%>
<%end%>functionRooms
<%@function_room.each do |functionroom|%><%= functionroom.name%>
<%= number_to_currency(functionroom.price)%>
<%= 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