Here I'll show you
- How to override devise registrations_controller(related to create/update user account)
- How to change redirect path after updating user
| #Deploy and rollback on Heroku in staging and production | |
| task :deploy_staging => ['deploy:set_staging_app', 'deploy:push', 'deploy:restart', 'deploy:tag'] | |
| task :deploy_production => ['deploy:set_production_app', 'deploy:push', 'deploy:restart', 'deploy:tag'] | |
| namespace :deploy do | |
| PRODUCTION_APP = 'YOUR_PRODUCTION_APP_NAME_ON_HEROKU' | |
| STAGING_APP = 'YOUR_STAGING_APP_NAME_ON_HEROKU' | |
| task :staging_migrations => [:set_staging_app, :push, :off, :migrate, :restart, :on, :tag] | |
| task :staging_rollback => [:set_staging_app, :off, :push_previous, :restart, :on] |
| =Navigating= | |
| visit('/projects') | |
| visit(post_comments_path(post)) | |
| =Clicking links and buttons= | |
| click_link('id-of-link') | |
| click_link('Link Text') | |
| click_button('Save') | |
| click('Link Text') # Click either a link or a button | |
| click('Button Value') |
| # autoload concerns | |
| module YourApp | |
| class Application < Rails::Application | |
| config.autoload_paths += %W( | |
| #{config.root}/app/controllers/concerns | |
| #{config.root}/app/models/concerns | |
| ) | |
| end | |
| end |
| $(document).ready(function() { | |
| // Support for AJAX loaded modal window. | |
| // Focuses on first input textbox after it loads the window. | |
| $('[data-toggle="modal"]').click(function(e) { | |
| e.preventDefault(); | |
| var url = $(this).attr('href'); | |
| if (url.indexOf('#') == 0) { | |
| $(url).modal('open'); | |
| } else { |
| brew update | |
| brew versions FORMULA | |
| cd `brew --prefix` | |
| git checkout HASH Library/Formula/FORMULA.rb # use output of "brew versions" | |
| brew install FORMULA | |
| brew switch FORMULA VERSION | |
| git checkout -- Library/Formula/FORMULA.rb # reset formula | |
| ## Example: Using Subversion 1.6.17 | |
| # |
| #Model | |
| @user.should have(1).error_on(:username) # Checks whether there is an error in username | |
| @user.errors[:username].should include("can't be blank") # check for the error message | |
| #Rendering | |
| response.should render_template(:index) | |
| #Redirecting | |
| response.should redirect_to(movies_path) |
| class AppDelegate | |
| def application(application, didFinishLaunchingWithOptions:launchOptions) | |
| @window = UIWindow.alloc.initWithFrame UIScreen.mainScreen.bounds | |
| @window.rootViewController = GoogleViewController.alloc.init | |
| @window.makeKeyAndVisible | |
| true | |
| end | |
| end |
| # install and make run basic bootstrap date-picker functionality described here http://www.eyecon.ro/bootstrap-datepicker/ | |
| # app/assets/javascript/datepicker.js.coffee | |
| $(document).on 'pageChanged', -> | |
| # datepicker for simple_form & Ransack | |
| $(".custom_datepicker_selector").datepicker().on 'changeDate', (en) -> | |
| correct_format = en.date.getFullYear() + '-' + ('0' + (en.date.getMonth() + 1)).slice(-2) + '-' + ('0' + en.date.getDate()).slice(-2) # date format yyyy-mm-dd | |
| $(this).parent().find("input[type=hidden]").val(correct_format) |
| require 'haml' | |
| # Do not buffer output | |
| $stdout.sync = true | |
| # Get working dir, fixes issues when rackup is called outside app's dir | |
| root_path = Dir.pwd | |
| use Rack::Static, | |
| :urls => ['/stylesheets', '/images', '/javascripts', '/fonts'], | |
| :root => root_path |