Search Results

Search found 2 results on 1 pages for 'ruevaughn'.

Page 1/1 | 1 

  • Why rails app is redirecting unexpectedly instead of matching the route?

    - by ruevaughn
    I asked this question earlier and thought it was fixed, but it's not. Previous question here My problem is I am trying to set my routes so that when I type in localhost:3000/sites/admin It should redirect to localhost:3000/en/sites/admin here is my routes.rb file scope ":locale", locale: /#{I18n.available_locales.join("|")}/ do get "log_out" => "sessions#destroy", as: "log_out" get "log_in" => "sessions#new", as: "log_in" resources :sites, except: [:new, :edit, :index, :show, :update, :destroy, :create] do collection do get :home get :about_us get :faq get :discounts get :services get :contact_us get :admin get :posts end end resources :users resources :abouts resources :sessions resources :coupons resources :monthly_posts resources :reviews resources :categories do collection { post :sort } resources :children, :controller => :categories, :only => [:index, :new, :create, :new_subcategory] end resources :products do member do put :move_up put :move_down end end resources :faqs do collection { post :sort } end root :to => 'sites#home' match "/savesort" => 'sites#savesort' end match '', to: redirect("/#{I18n.default_locale}") match '*path', to: redirect("/#{I18n.default_locale}/%{path}") But as of right now, it redirects to /en/en/en/en/en/en/en/en/en/en/sites/admin (adds en until browser complains). Any thoughts why it keeps adding /en?

    Read the article

  • Proper way to use before_create

    - by ruevaughn
    Pretty basic question here, I need to write a before filter on my Category model, to ensure that the depth never reaches more than 2. Here is what I have so far. app/models/category.rb before_create :check_depth def check_depth self.depth = 1 if depth > 2 end I need it instead of setting depth to 1, just to return a error message, but I can't even get this current setup to work, I get the error undefined method `>' for nil:NilClass So, instead of setting the depth to one like I'm trying to do how would I send an error instead? And any help getting the current function working for informational purposes? Thanks in advance

    Read the article

1