~ rvm install 2.3.1
~ rvm use --default 2.3.1
~ rvm use 2.3.1@Gemset_pcm --create
~ rvm gemset list_all
~ gem install rails 4.2.7
- Comando erroneo al no colocar
v 4.2.7
, provoco que se intalara Rails 5 - Lo corregimos con
~ gem install rails v 4.2.7
, con esto tenemos las dos gemas intaladas.
~ rails _4.2.7_ new [nombre_del_proyecto]
use-rails-4-secrets-yml-for-database-config
- Update .gitignore to include config/secrets.yml
- Add the a database section to config/secrets.yml Note the explicit use of symbols.
development:
database:
:host: localhost
:name: my_project_development
:username: root
:password: password
- add database section to all envs...
- Update config/database.yml to look like something like this.
default: &default
host: <%= Rails.application.secrets[:database][:host] %>
adapter: postgresql
encoding: UTF8
database: <%= Rails.application.secrets[:database][:name] %>
pool: 10
reaping_frequency: 30
username: <%= Rails.application.secrets[:database][:username] %>
password: <%= Rails.application.secrets[:database][:password] %>
development: *default
test: *default
production: *default
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .
*
*= require_tree .
*= require_self
Example with form_for and posting to user_session_path:
<%= form_for(:user, :url => session_path(:user)) do |f| %>
<%= f.text_field :email %>
<%= f.password_field :password %>
<%= f.check_box :remember_me %>
<%= f.label :remember_me %>
<%= f.submit 'Sign in' %>
<%= link_to "Forgot your password?", new_password_path(:user) %>
<% end %>
Note: "user" in this context is the resource you specified when setting up Devise.
Warning for client_side_validations Whilst the above method works, it should be noted that using the name of a resource as the first parameter for form_for is now deprecated in Rails. I ran into this problem whilst trying to integrate client_side_validations with devise and it choked on this form. I don't know if this is the best work around but in the end, I got it working by leaving the devise form_for as it looks normally: @form_for(resource, :as => resource_name ... )@
Now the trick is defining those helper methods in other controllers. Assuming your devise model is called "user", place the following methods either in the helper class of the controller you are using to display the form or in your application helper:
helper_method :resource_name, :resource, :devise_mapping
def resource_name
:user
end
def resource
@resource ||= User.new
end
def devise_mapping
@devise_mapping ||= Devise.mappings[:user]
end
Another advantage of this method is that you don't need to alter the default devise forms. Just move them into a partial and render them wherever you want.
Source: "http://pupeno.com/blog/show-a-devise-log-in-form-in-another-page/":