Using Devise tokens to log in, is this built in?

My understanding is that you can use the tokens to log in or to hit arbitrary pages that need authentication, even with cURL. If you look in config/initializers/devise.rb, there should be a line that says something like: config.token_authentication_key = :auth_token Whatever the name of the token_authentication_key is should match what you put as the query …

Read more

Understanding Gemfile.lock: Is it okay to delete Gemfile.lock then run bundle install again?

You’re probably not going to ruin your dev environment. However, you might end up with newer versions of gems than you had before. It depends on how you have defined them in Gemfile. If you’re using entries like: gem “rails” Then you’ll get the latest rails gem, whatever that might be. If you’re using entries …

Read more

How do I access the Rack environment from within Rails?

I’m pretty sure you can use the Rack::Request object for passing request-scope variables: # middleware: def call(env) request = Rack::Request.new(env) # no matter how many times you do ‘new’ you always get the same object request[:foo] = ‘bar’ @app.call(env) end # Controller: def index if params[:foo] == ‘bar’ … end end Alternatively, you can get …

Read more

Need two indexes on a HABTM join table?

Close – you most likely want the following: add_index :person_products, [:person_id, :product_id], :unique => true add_index :person_products, :product_id The :unique => true is not strictly required and it depends whether or not it makes sense to have a person associated with a product multiple times. I would say if you’re not sure, you probably do …

Read more