How do I see the ENV vars in a Rails app?

Assuming the staging environment, as your example points to. You’ll want to load the console by prepending the RAILS_ENV environment variable to the rails console command. RAILS_ENV=staging rails console That should get you in. Once you’re in, you can just access the ENV variable directly. 2.2.2 (main):0 > ENV And that will dump out the … Read more

How do I redirect to root – public/index.html?

You can assign a named route to a static file by passing any non-empty string as :controller and the path to the file as the :action for the route: Application.routes.draw do root :controller => ‘static’, :action => “https://stackoverflow.com/” # or # root :controller => ‘static’, :action => ‘/public/index.html’ end # elsewhere redirect_to root_path # redirect … Read more

Passing param values to redirect_to as querystring in rails

The ‘Record’ form of redirect_to uses the second argument only for the response status. You’ll have to use another form of redirect_to, like the ‘String’ form. e.g.: redirect_to thing_path(@thing, :foo => params[:foo]) which will work for nested params[:foo] params like you mentioned. Or, as Drew commented below, you can use polymorphic_url (or _path): redirect_to polymorphic_path(@thing, … Read more

Ruby formatting for ordinals: ‘1’ as ‘1st’, ‘2’ as ‘2nd’ etc

Looks like you are looking for ordinalize: The Ruby on Rails framework is chock full of interesting little nuggets. Ordinalize is a number extension that returns the corresponding ordinal number as a string. For instance, 1.ordinalize returns “1st” and 22.ordinalize return “22nd”. Example: place = 3 puts “You are currently in #{place.ordinalize} place.” Result: You … Read more

How to write controller tests when you override devise registration controller?

The problem is that Devise is unable to map routes from the test back to the original controller. That means that while your app actually works fine if you open it in the browser, your controller tests will still fail. The solution is to add the devise mapping to the request before each test like … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)