Advertisement
Guest User

Untitled

a guest
Nov 11th, 2014
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.30 KB | None | 0 0
  1. rails new img
  2. cd img
  3. echo "
  4. gem 'devise'
  5. gem 'better_errors'
  6. " >> Gemfile
  7. bundle install
  8. rails generate devise:install
  9. rails g devise user name:string
  10. rails g scaffold image filename:string private:boolean user:references
  11. rails g scaffold Tag tag_string:string image:references
  12. rails g scaffold acl image:references user:references
  13. rails g devise:views
  14. rails g devise:controllers user
  15. rake db:migrate
  16. cat << EOF > ./app/views/devise/registrations/new.html.erb
  17. <h2>Sign up</h2>
  18.  
  19. <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
  20.   <%= devise_error_messages! %>
  21.  
  22. <div class="field">
  23.     <%= f.label :name %><br />
  24.     <%= f.name_field :name, autofocus: true %>
  25.   </div>
  26.  
  27.   <div class="field">
  28.     <%= f.label :email %><br />
  29.     <%= f.email_field :email, autofocus: true %>
  30.   </div>
  31.  
  32.   <div class="field">
  33.     <%= f.label :password %>
  34.     <% if @validatable %>
  35.     <em>(<%= @minimum_password_length %> characters minimum)</em>
  36.     <% end %><br />
  37.     <%= f.password_field :password, autocomplete: "off" %>
  38.   </div>
  39.  
  40.   <div class="field">
  41.     <%= f.label :password_confirmation %><br />
  42.     <%= f.password_field :password_confirmation, autocomplete: "off" %>
  43.   </div>
  44.  
  45.   <div class="actions">
  46.     <%= f.submit "Sign up" %>
  47.   </div>
  48. <% end %>
  49.  
  50. <%= render "devise/shared/links" %>
  51. EOF
  52. cat << EOF > ./app/controllers/user/registrations_controller.rb
  53. class User::RegistrationsController < Devise::RegistrationsController
  54.   protected
  55.   def sign_up_params
  56.     params.require(:user).permit(:name, :email, :password, :password_confirmation)
  57.   end
  58.  
  59.   def account_update_params
  60.     params.require(:user).permit(:name, :email, :password, :password_confirmation, :current_password)
  61.   end
  62. end
  63. EOF
  64. cat << EOF > ./config/routes.rb
  65. Rails.application.routes.draw do
  66.   resources :acls
  67.   resources :tags
  68.   resources :images
  69.   devise_for :users
  70.   root to: 'images#index'
  71. end
  72. EOF
  73. sed -i '' -e'3irespond_to :html, :xml, :json' app/controllers/images_controller.rb 2>/dev/null
  74. sed -i '' -e'3irespond_to :html, :xml, :json' app/controllers/acls_controller.rb 2>/dev/null
  75. sed -i '' -e'3irespond_to :html, :xml, :json' app/controllers/application_controller.rb 2>/dev/null
  76. sed -i '' -e'3irespond_to :html, :xml, :json' app/controllers/tags_controller.rb 2>/dev/null
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement