I'm trying to hide this button from all the show pages of the Rooms model. I have an array of the rooms id stored in #extra but whenever I try to use current_page?(room_path(#extra)) it doesn't work, but when I specify the id, for example, current_page?(room_path(6)) it works and hides the button. What am I doing wrong?
<% unless current_page?(controller: 'rooms') || current_page?(room_path(#extra))%>
<button onclick="myFunction()" class="button btn btn-light bg-white rounded-pill shadow-sm px-4 mb-4"
style="vertical-align:middle">
<span>
<small class="text-uppercase font-weight-bold"> Nav-bar Toggle</small>
</span>
</button>
<% end %>
routes/rb
require 'sidekiq/web'
Rails.application.routes.draw do
resources :messages
resources :rooms
# Routing for budget section
resources :budgets do
resources :groups do
resources :categories
end
end
resources :posts do
resources :likes
resources :comments
end
resources :socials
resources :mentions, only: [:index]
resources :mentioned_posts, only: [:index]
resources :follows
resources :followers, only: [:index]
resources :followings, only: [:index]
resources :accounts
resources :goals
resources :retirements
get '/users', to: 'users#index'
get '/user/:id', to: 'users#show', as: 'user'
resources :calculate_debts
get '/privacy', to: 'home#privacy'
get '/terms', to: 'home#terms'
authenticate :user, lambda { |u| u.admin? } do
mount Sidekiq::Web => '/sidekiq'
end
resources :notifications, only: [:index]
resources :announcements, only: [:index]
devise_for :users, controllers: { omniauth_callbacks: "users/omniauth_callbacks" }
root to: 'home#index'
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
end
Based on the information provided in the comments. The show path needs an id to be complete. You can check it with,
current_page?(controller: 'rooms', action: 'show', id: room_id)
instead of
current_page?(controller: 'rooms', action: 'show')
If you want to check against a particular room id, you can use
current_page?(controller: 'rooms', action: 'show', id: room_id)
If you want to check just the controller and action, irrespective of the room id, you'll have to use another strategy. You can use,
if params[:controller] == :rooms && params[:action] == :show
or match against a regex
if request.fullpath =~ /\/rooms\/\d+/
Related
how can I organize routing for /admin section with arguments before the "/admin".
For example, /:country_id/:lang_id/admin
Path example, /ukraine/english/admin
I have tried:
scope path:"/:country_id/:lang_id/admin", :as => "admin" do
resources :cities, controller:'admin/cities'
but "admin_cities_path" create wrong internal links
<%= link_to city.title, admin_cities_path(city.id) %>
Rails returns the following UR:: /1/english/admin/cities
instead of:
/ukraine/english/admin/cities/1
Routes.rb
Rails.application.routes.draw do
devise_for :users
devise_for :views
get 'home/index', to: 'application#index'
root to: "home#index"
get '/:id/:lang_id/admin', to: 'admin/admin#index'
get '/admin', to: 'admin/admin#index'
scope path:"/:country_id/:lang_id/admin", :as => "admin" do
#namespace :admin do
resources :cities, controller:'admin/cities'
resources :comments do
member do
get 'approve'
get 'disapprove'
end
end
resources :countries
resources :industries
resources :products
resources :languages
resources :categories
resources :companies
end
#root "articles#index"
#get "/admin/countries", to: "countries#index"# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
# resources :countries do
# resources :languages
# end
resources :countries
get '/countries/', to: 'countries#index'
get '/languages/', to: 'languages#index'
get '/:id/', to: 'countries#show', as: 'localized_country'
get '/:id/:lang_id/', to: 'languages#show', as: 'localized_language'
#get '/:id/:lang_id/:category_id/', to: 'categories#show', as: 'localized_category'
get '/:id/:lang_id/:industry_id/', to: 'industries#show', as: 'localized_industry'
get '/:id/:lang_id/:industry_id/:category_id/', to: 'categories#show', as: 'localized_category'
get '/:id/:lang_id/:industry_id/:category_id/:city_id/', to: 'cities#show', as: 'localized_city'
get '/:id/:lang_id/:industry_id/:category_id/product/:product_id/', to: 'products#show', as: 'localized_product'
resources :languages, param: :land_id
resources :products
resources :industries
resources :categories, param: :category_id
resources :products do
resources :comments
end
end
I am just guessing what you want if its not satisfied then pls comments some code or more information to solve it.
resources :country, path: '' do
resources :language, path: '' do
namespace "admin" do
resource :cities
end
end
end
The above code will reporduce the path in following format.
new_country_language_admin_cities GET /:country_id/:language_id/admin/cities/new(.:format) admin/cities#new
edit_country_language_admin_cities GET /:country_id/:language_id/admin/cities/edit(.:format) admin/cities#edit
and so on...
I have resources :subjects in my routes which I wants to use as optional routes by using concern.
The idea is to use DRY approach so I do not need to re-write routes lines for other case in which I do not need resources :subjects.
The links are like below and it is clear I have no subject_id in 2nd case as I do not need it:
http://localhost:3000/teacher/katherine-fleming/subjects/3/lesson_plans/3
and
http://localhost:3000/teacher/carmel-cynthia/lesson_plans/3
Right now, it stops working for both cases and saying:
ActionController::RoutingError (No route matches [GET] "/teacher
/katherine-fleming/subjects/3/lesson_plans/3"):
ActionController::RoutingError (No route matches [GET] "/teacher/carmel-
cynthia/lesson_plans/68"):
My routes for case 1 are:
resources :subjects do
concern :lesson_plans, :except => [:index] do
resources :lesson_plan_registrations
resources :comments, only: [:new, :create, :destroy]
end
end
I am trying to make them working using below code but its not working as expected.
resources :lesson_plans, concerns: :lesson_plans
What's working right now is:
resources :subjects do
resources :lesson_plans, :except => [:index] do
resources :lesson_plan_registrations
resources :comments, only: [:new, :create, :destroy]
end
end
resources :lesson_plans, :except => [:index] do
resources :lesson_plan_registrations
resources :comments, only: [:new, :create, :destroy]
end
But its something to re-write the whole code again for the case in which I do not need resources :subjects.
I want to use DRY approach so it will work for both cases.
Here are full routes.rb file:
Rails.application.routes.draw do
root 'welcome#index'
devise_for :users, controllers: {sessions: 'sessions', registrations: 'registrations', :omniauth_callbacks => 'omniauth_callbacks'}
resources :requested_schools, only: [:new, :create]
resources :tags, only: :index
resources :specializations, only: :index
resources :search, only: :index
get '/fetch_schools' => 'search#fetch_schools'
get '/fetch_subjects' => 'search#fetch_subjects'
resources :search_results do
collection do
get '/lesson_plan' => 'search_results#lesson_plan', as: :lesson_plan
get '/video' => 'search_results#video', as: :video
get '/document' => 'search_results#document', as: :document
get '/note' => 'search_results#note', as: :note
end
end
namespace :admin do
root 'dashboard#index'
get 'login' => 'sessions#new', as: :login
resources :dashboard, only: [:index]
resources :requested_schools, only: [:index, :edit, :edit, :show, :destroy] do
member do
get :accept_request
get :decline_request
get 'view_files' => 'requested_schools#view_files', as: :view_files
get 'imported_data' => 'requested_schools#imported_data', as: :imported_data
end
end
resource :users, :except => [:show, :index, :new, :create] do
member do
get :change_password
patch :update_password
end
end
end
namespace :school do
root 'dashboard#index'
resources :dashboard, :path => '/', only: [:index]
resources :departments do
resources :subjects
end
resources :class_rooms do
resources :class_room_subjects
resources :class_room_schedules
resources :class_room_registrations do
collection do
post "/student_registration" => "class_room_registrations#student_registration", as: :student_registration
end
end
end
get '/fetch_subject_teachers' => 'class_room_subjects#fetch_subject_teachers', as: :fetch_subject_teachers
resources :schools, :path => '/', only: [:index, :edit, :show, :destroy, :update] do
collection do
get :change_password
patch :update_password
get :edit_profile
patch :update_profile
get :listing
get :view_ids
match "/upload_ids" => "schools#upload_ids", via: [:get, :post]
get :autocomplete_school_name
get '/view_lesson_plan/:id' => "schools#view_lesson_plan", as: :view_lesson_plan
end
member do
get :students
get :teachers
get :lesson_plans
match '/class_rooms' => "class_rooms#index", via: [:get, :post]
end
end
end
resources :friend_requests do
member do
get '/send_friend_request/:type' => "friend_requests#send_friend_request", as: :send_friend_request
get '/decline_friend_request/:type' => "friend_requests#decline_friend_request", as: :decline_friend_request
get '/accept_friend_request/:type' => "friend_requests#accept_friend_request", as: :accept_friend_request
get '/cancel_friend_request/:type' => "friend_requests#cancel_friend_request", as: :cancel_friend_request
get '/unfriend' => "friend_requests#unfriend", as: :unfriend
end
collection do
get :friend_requests
end
end
namespace :student do
resources :students, :path => '/' do
member do
get :friends
get :lesson_plan_progress
post "/join_private_school/:school_id" => "students#join_private_school", as: :join_private_school
get "/private_schools" => "students#private_schools", as: :private_schools
end
collection do
get :departments
post :select_departments
get :list_departments
get :my_lesson_plan
get :special_lesson_plans
end
get '/view_result/:id' => "students#view_result", as: :view_result
get '/lesson_plan/:id' => "students#lesson_plan", as: :lesson_plan
get '/video/:id' => "students#video", as: :video
post '/video_comments/:id' => "students#video_comments", as: :video_comments
get '/like_video/:id' => "students#like_video", as: :like_video
get '/liked_video_users/:id' => "students#liked_video_users", as: :liked_video_users
get '/is_video_completed' => "students#is_video_completed", as: :is_video_completed
get '/assignment_result/:id' => "students#assignment_result", as: :assignment_result
end
resource :users, :except => [:show, :index, :new, :create] do
member do
get :change_password
patch :update_password
end
end
end
namespace :teacher do
resources :teachers, :path => '/' do
resources :subjects do
resources :lesson_plans, :except => [:index] do
member do
get '/change_public' => "lesson_plans#change_public", as: :change_public
get '/change_private' => "lesson_plans#change_private", as: :change_private
post '/copy_lesson_plan' => "lesson_plans#copy_lesson_plan", as: :copy_lesson_plan
get '/play_list_progress' => "lesson_plans#list_play_list_progress", as: :list_play_list_progress
end
resources :lesson_plan_registrations, :only => [:new, :create, :edit, :update]
post '/move_up_down_play_list' => 'lesson_plans#move_up_down_play_list', as: :move_up_down_play_list
resources :comments, only: [:new, :create, :destroy]
resources :videos do
member do
get '/like_video' => "videos#like_video", as: :like_video
get '/liked_video_users' => "videos#liked_video_users", as: :liked_video_users
get '/delete_video_comment' => "videos#delete_video_comment", as: :delete_video_comment
get '/is_video_completed' => "videos#is_video_completed", as: :is_video_completed
post '/copy_video' => "videos#copy_video", as: :copy_video
end
end
resources :documents do
member do
get '/download_file' => "documents#download_file", as: :download_file
get '/like_document' => "documents#like_document", as: :like_document
get '/liked_document_users' => "documents#liked_document_users", as: :liked_document_users
post '/copy_document' => "documents#copy_document", as: :copy_document
end
end
resources :notes do
member do
get '/like_note' => "notes#like_note", as: :like_note
get '/liked_note_users' => "notes#liked_note_users", as: :liked_note_users
end
end
resources :quizzes do
member do
get '/like_quiz' => "quizzes#like_quiz", as: :like_quiz
get '/liked_quiz_users' => "quizzes#liked_quiz_users", as: :liked_quiz_users
match '/change_public' => "quizzes#change_public", as: :change_public, via: [:get, :post]
get '/give_quiz' => "quizzes#give_quiz", as: :give_quiz
get '/preview_quiz' => "quizzes#preview_quiz", as: :preview_quiz
post '/copy_quiz' => "quizzes#copy_quiz", as: :copy_quiz
end
resources :questions do
collection do
get '/fetch_question_options' => 'questions#fetch_question_options'
match '/search_questions' => 'questions#search_questions', as: :search_questions, via: [:get, :post]
post '/select_questions' => 'questions#select_questions', as: :select_questions
end
end
resources :question_groups
resources :sort_questions, only: [:index]
post '/move_up_down' => 'sort_questions#move_up_down', as: :move_up_down
resources :quiz_answers, only: [:new, :create]
resources :quiz_attempts do
member do
get '/download_file' => "quiz_attempts#download_file", as: :download_file
end
end
end
resources :question_banks do
member do
get :fetch_picks
end
resources :sort_questions, only: [:index]
resources :questions do
member do
post :move
end
collection do
get '/fetch_question_options' => 'questions#fetch_question_options'
end
end
end
resources :assignments do
member do
match '/change_public' => "assignments#change_public", as: :change_public, via: [:get, :post]
get '/like_assignment' => "assignments#like_assignment", as: :like_assignment
get '/liked_assignment_users' => "assignments#liked_assignment_users", as: :liked_assignment_users
get '/download_file' => "assignments#download_file", as: :download_file
post '/copy_assignment' => "assignments#copy_assignment", as: :copy_assignment
end
resources :assignment_submissions do
member do
get '/download_file' => "assignment_submissions#download_file", as: :download_file
post '/mark_assignment' => "assignment_submissions#mark_assignment", as: :mark_assignment
end
end
end
end
end
resources :lesson_plans do
resources :videos
resources :documents
resources :notes
resources :quizzes do
member do
match '/change_public' => "quizzes#change_public", as: :change_public, via: [:get, :post]
get '/preview_quiz' => "quizzes#preview_quiz", as: :preview_quiz
end
resources :questions
resources :quiz_attempts do
member do
get '/download_file' => "quiz_attempts#download_file", as: :download_file
end
end
end
resources :question_banks
resources :assignments
end
resources :class_rooms, :only => [:index] do
resources :subjects do
resources :subject_grades, only: [:index] do
collection do
get "/mark_complete" => "subject_grades#mark_complete", as: :mark_complete
end
end
resources :class_room_subjects, only: [:update]
resources :lessons do
resources :attendances, only: [:index]
end
end
end
resources :private_schools do
resources :invitation_promo_codes
resources :private_classes do
member do
get :new_private_lesson_plan
post :create_private_lesson_plan
get "/edit_private_lesson_plan/:private_lesson_plan_id" => "private_classes#edit_private_lesson_plan", as: :edit_private_lesson_plan
post "/update_private_lesson_plan/:private_lesson_plan_id" => "private_classes#update_private_lesson_plan", as: :update_private_lesson_plan
get "/destroy_private_lesson_plan/:private_lesson_plan_id" => "private_classes#destroy_private_lesson_plan", as: :destroy_private_lesson_plan
end
end
end
member do
get :friends
get '/lesson_plans' => "lesson_plans#index", as: :lesson_plans
get '/my_class_rooms' => "class_rooms#index", as: :my_class_rooms
get :new_promo_code
post :create_promo_code
post :leave_private_school
end
collection do
get :departments
post :select_departments
get '/:teacher_id/invitation_promo_codes' => "invitation_promo_codes#index", as: :invitation_promo_codes
end
end
resource :users, :except => [:show, :index, :new, :create] do
member do
get :change_password
patch :update_password
end
end
end
get '/notifications' => 'users#notifications', as: :notifications
delete '/delete_notification/:id' => 'users#delete_notification', as: :delete_notification
get '/notification_status' => 'users#notification_status'
end
You can try this in your routes:
def lesson_plans
resources :lesson_plans, :except => [:index] do
resources :lesson_plan_registrations
resources :comments, only: [:new, :create, :destroy]
end
end
resources :subjects do
lesson_plans
end
lesson_plans
Better way,
concern :lesson_plans do
resources :lesson_plans, :except => [:index] do
resources :lesson_plan_registrations
resources :comments, only: [:new, :create, :destroy]
end
end
resources :subjects do
concerns :lesson_plans
end
concerns :lesson_plans
On the home page:
sessions/_goal.html.erb
<%= simple_form_for(:session, url: new_goal_path) do |f| %>
<%= f.text_field :name %>
<%= f.submit %>
<% end %>
# ERROR MESSAGE:
Routing Error
No route matches [POST] "/goals/new"
Once the user submit's that he should be redirected to:
sessions/_habit.html.erb
<%= simple_form_for(:session, url: new_habit_path) do |f| %>
<%= f.text_field :name %>
<%= f.submit %>
<% end %>
Once the user submit's that he should be redirected to:
<%= link_to "Sign Up via Facebook", "/auth/facebook" %> or
<%= link_to "Sign Up via Email", signup_path %>
The information they put in those two partials should then be stored so that when they are signed in they will see it as part of their profile.
sessions_controller.rb
class SessionsController < ApplicationController
def new
end
def goal
end
def facebook
user = User.from_omniauth(env["omniauth.auth"])
session[:user_id] = user.id
redirect_to root_url
end
def create
user = User.find_by(email: params[:session][:email].downcase)
if user && user.authenticate(params[:session][:password])
if user.activated?
log_in user
params[:session][:remember_me] == '1' ? remember(user) : forget(user)
redirect_to root_url
else
message = "Account not activated. "
message += "Check your email for the activation link."
flash[:warning] = message
redirect_to root_url
end
else
flash.now[:danger] = 'Invalid email/password combination'
render 'new'
end
end
def destroy
log_out if logged_in?
redirect_to root_url
end
end
routes
Rails.application.routes.draw do
put '/mark_completed/:id', to: 'habits#mark_completed', as: 'mark_completed'
put '/mark_accomplished/:id', to: 'goals#mark_accomplished', as: 'mark_accomplished'
get 'notes/index'
get 'notes/new'
get 'notifications/index'
get 'auth/:provider/callback', to: 'sessions#facebook'
get 'auth/failure', to: redirect('/')
get 'signout', to: 'sessions#destroy', as: 'signout'
get 'password_resets/new'
get 'password_resets/edit'
get "/users/:user_id/goals", to: "goals#user_goals", as: "user_goals"
shallow do
resources :habits do
resources :comments
resources :notes
resources :notifications
end
resources :valuations do
resources :comments
resources :notes
resources :notifications
end
resources :goals do
resources :comments
resources :notes
resources :notifications
end
resources :stats do
resources :comments
resources :notes
resources :notifications
end
end
resources :notes
resources :habits do
collection { post :sort }
resources :notes
resources :notifications
resources :comments do
resources :likes
end
resources :likes
member do
post :like
post :notifications
end
resources :levels do
# we'll use this route to increment and decrement the missed days
resources :days_missed, only: [:create, :destroy]
end
end
resources :goals do
resources :notes
resources :comments
member do
post :like
end
end
resources :valuations do
resources :notes
resources :comments
resources :notifications
member do
post :like
post :notifications
end
end
resources :stats do
resources :notes
resources :comments
resources :notifications
member do
post :like
end
end
resources :results
resources :users
resources :account_activations, only: [:edit]
resources :activities do
resources :valuations
resources :habits
resources :stats
resources :goals
end
resources :notifications do
resources :valuations
resources :habits
resources :stats
resources :goals
resources :comments
end
resources :comments do
resources :comments
resources :notifications
member do
post :like
end
end
resources :password_resets, only: [:new, :create, :edit, :update]
resources :relationships, only: [:create, :destroy]
get 'tags/:tag', to: 'pages#home', as: :tag
resources :users do
member do
get :following, :followers
end
end
get 'about' => 'pages#about'
get 'signup' => 'users#new'
get 'login' => 'sessions#new'
post 'login' => 'sessions#create'
delete 'logout' => 'sessions#destroy'
root 'pages#home'
I have no idea what I'm doing here. Any help would greatly be appreciated :]
That will take some work.
First, fix your routes (post them here as you was rightfully asked).
Next, change your partials into action templates (remove underscore _ from their names).
Then in your controller actions use params[...] to retrieve data (e.g. params[:session][:name] for the first step) and save them in session (session[:name] = params[:session][:name]).
At the end of action call redirect_to :another_action (change :another_action to the concrete action you want next – for example in goal method that would be redirect_to :habit_url – and you should add that habit method to your controller).
Then, in your facebook-related methods you will have session[:name] and other stuff available, so you just fetch it from there and push into database (user.update(name: session[:name])).
Reading material:
Action Controller Overview – you need to attentively read this first of all
Active Record Basics – how to save user details to database
Rails Routing from the Outside In – just look through that, paying attention to places which are relevant to your current setup
Please help me, I am working on a rails project and I've created a view file with extension .html.haml but now when I am trying to view the output of that file it is giving an error. Is there any other method to view the files of such extension, I am using the way as i use to view my file with exyension .html.erb. I've created an action in controller nd matches the path in routes.rb. Please help me , Thanks in advance.
My routes.rb file is
PretAChef::Application.routes.draw do
# mount FeatherCms::Engine => "/feathers"
# get 'pages/:name' => 'feather_cms/pages#published', :as => 'feather_published_page'
resources :messages, only: [:destroy, :show] do
member do
post :reply
get :mark_read
end
end
resources :bookings, only: [] do
resources :messages, only: [:new, :create]
end
resources :chefs, :only => [:index, :show] do
member do
get :feedbacks
end
end
resources :customers, :only => [] do
member do
get :feedbacks
end
end
resources :ingredients, only: [:index]
resources :cuisines, only: [:index]
resources :home do
collection do
post :contact
end
end
root :to => 'home#index'
match 'contact_us' => 'home#contact_us', :as => :contact_us
match 'mypop' => 'chefs#mypop', :as => :mypop
devise_for :users, :controllers => {:registrations => "users/registrations", :sessions => "users/sessions", :passwords => "users/passwords", :confirmations => "users/confirmations", :omniauth_callbacks => "users/omniauth_callbacks" }
devise_scope :user do
match "/chef/sign_up" => "users/registrations#new_chef", as: :chef_sign_up
match "/chef/sign_in" => "users/sessions#new_chef", as: :chef_sign_in
match "/users/sign_out" => "users/sessions#destroy", as: :sign_out
end
resource :profiles, :only => [:edit, :update] do
end
namespace :customer do
resource :dashboards, only: [:show]
resources :bookings, :only => [:create, :update, :edit, :destroy] do
collection do
get :booking_confirmation
get :book_chef
end
member do
# TODO: WTF: use destroy for cancelation
post :rate
post :comment
get :feedback
get :pay
get :complete
get :confirm
end
end
end
namespace :admin do
resources :messages, only: [:index, :show] do
collection do
get :contact_us
get :messages
end
end
resources :cuisines, except: [:show]
resources :bookings, only: [:index, :update, :edit, :destroy]
resources :users, only: [:index, :update, :edit] do
collection do
get :active
get :pending
end
resources :menus, except: [:index] do
collection do
post :preview
get :destory_dish_image
end
end
resources :availabilities, only: [:create, :destroy]
resources :chef_messages, only: [:destroy, :show, :index, :new, :create] do
member do
post :reply
get :mark_read
end
end
namespace :chef do
resources :bookings, only: [:edit, :update] do
member do
get :accept
post :rate
post :comment
get :feedback
end
end
end
end
resources :searches, only: [:index] do
collection do
get "user"
end
end
end
namespace :chef do
resources :bookings, only: [:edit, :update] do
member do
get :accept
post :rate
post :comment
get :feedback
end
end
resource :dashboards, only: [:show]
resources :menus, except: [:index] do
collection do
post :preview
get :destory_dish_image
end
end
resources :availabilities, only: [:create, :destroy]
end
# The priority is based upon order of creation:
# first created -> highest priority.
# Sample of regular route:
# match 'products/:id' => 'catalog#view'
# Keep in mind you can assign values other than :controller and :action
# Sample of named route:
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
# This route can be invoked with purchase_url(:id => product.id)
# Sample resource route (maps HTTP verbs to controller actions automatically):
# resources :products
# Sample resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end
# Sample resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end
# Sample resource route with more complex sub-resources
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', :on => :collection
# end
# end
# Sample resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
# You can have the root of your site routed with "root"
# just remember to delete public/index.html.
# root :to => 'welcome#index'
# See how all your routes lay out with "rake routes"
# This is a legacy wild controller route that's not recommended for RESTful applications.
# Note: This route will make all actions in every controller accessible via GET requests.
# match ':controller(/:action(/:id))(.:format)'
end
and my view file is
!!!
%html
%head
:css
/* popup_box DIV-Styles*/
#popup_box {
display:none; /* Hide the DIV */
position:fixed;
_position:absolute; /* hack for internet explorer 6 */
height:300px;
width:600px;
background:#FFFFFF;
left: 300px;
top: 150px;
z-index:100; /* Layering ( on-top of others), if you have lots of layers: I just maximized, you can change it yourself */
margin-left: 15px;
/* additional features, can be omitted */
border:2px solid #ff0000;
padding:15px;
font-size:15px;
-moz-box-shadow: 0 0 5px #ff0000;
-webkit-box-shadow: 0 0 5px #ff0000;
box-shadow: 0 0 5px #ff0000;
}
#container {
background: #d2d2d2; /*Sample*/
width:100%;
height:100%;
}
a{
cursor: pointer;
text-decoration:none;
}
/* This is for the positioning of the Close Link */
#popupBoxClose {
font-size:20px;
line-height:15px;
right:5px;
top:5px;
position:absolute;
color:#6fa5e2;
font-weight:500;
}
%title Popup Box DIV
%script{src: "http://jqueryjs.googlecode.com/files/jquery-1.2.6.min.js", type: "text/javascript"}
:javascript
$(document).ready( function() {
// When site loaded, load the Popupbox First
loadPopupBox();
$('#popupBoxClose').click( function() {
unloadPopupBox();
});
$('#container').click( function() {
unloadPopupBox();
});
function unloadPopupBox() { // TO Unload the Popupbox
$('#popup_box').fadeOut("slow");
$("#container").css({ // this is just for style
"opacity": "1"
});
}
function loadPopupBox() { // To Load the Popupbox
$('#popup_box').fadeIn("slow");
$("#container").css({ // this is just for style
"opacity": "0.3"
});
}
});
%body
#popup_box
/ OUR PopupBox DIV
%h1 This IS A Cool PopUp
%a#popupBoxClose Close
#container
/ Main Page
%h1 sample
and my action is mypop in chefs controller.
It seems you have not installed a gem for it. All you need to do is add gem "haml" to your Gemfile. Run bundle install
And you're done.
First of all you need to place all your css and script under assets and not on the template itself and secondly can you explain your problem a little. I mean what action are you calling, how are you rendering your file and to which action its going
I'm trying to define a route in routes.rb and I can't do anything from this Ruby on Rails routing guide that will let this error pass.
No route matches {:controller=>"devise/home"}
Here's my routes.rb source.
SchoolCMS::Application.routes.draw do
root :to => "home#index"
devise_for :teachers, :admin
resources :home, :only => :index
resources :admin, :only => :index
resources :events do
resources :event
end
resources :posts do
resources :comments
end
end
Just to be safe I would remove devise_for :teachers, :admin and split it so that it is
devise_for :teachers
devise_for :admin
I'm not sure you can specify multiple devises the way you use it, see if this fixes your error.
Also try to use path helpers were possible so instead of doing <%= link_to 'Home', :controller => 'home' %> make it <%= link_to 'Home', homes_path %> but make sure you define your home as resource :home, :only => :show since it's a singular resource.