Ruby
The command which -a ruby
will show you where Ruby is installed.
which -a ruby
Save user and modify
u = User.find_by(email: "<EMAIL>")
# Then run commands like below
# u.access_locked = false
# u.access_locked?
DB Dump Steps
# Create DB via PgAdmin App
pg_restore --port 5432 --username logeshpaul --dbname mdr_staging --no-password --verbose /Users/logeshpaul/Downloads/
.env file DATABASE_NAME_DEVELOPMENT=mdr_staging
./bin/dev
# Alternate Method shared by Lordson
psql DB_NAME < sce_dump.sql
Time
# current time
Time.now # 2009-06-24 12:39:54 +0900
# Return Time string with certain format - dd-Mon-yyyy HH:MM am/pm
"%d-%b-%Y %-l:%M%P" # 27-Jan-2016 7:19am
"%d/%m/%Y %-l:%M%P" # 27/01/2016 7:19am
More about Time API - Link
Changing the format of Date & Time
<%= Time.now.strftime("%m/%d/%Y") %>
<%= DateTime.now.strftime("%m/%d/%Y") %>
<%= DateTime.now.strftime("%e-%b-%Y %m:%M %p %Z") %>
# outputs - 12-Feb-2016 07:05 PM IST
In case you want a custom format use Strftime
Populate projects and studies in sce
rake sycamore:dashboard:seed[1,1,50,50,50]
Enable / Disable Form, Codelist, etc
rake app:admin:features:enable["Pharma","new_vrep"]
rake app:admin:features:enable["Pharma","new_standard"]
Enable / Disabled Editor
rails c
a = Organization.last
a.ff_react_editor = true
a.save
Clear local DB (Like prime for SCE)
rake db:setup db:test:prepare
Create fixtures in MDR
rails c
StandardFixtures.create
Run Specs
Run all tests - bundle exec rake spec SPEC_OPTS="--format documentation"
Run server in production environment
rails s -p 9000 -e production
Assets
rake assets:clean
rake assets:precompile
rake -T
Jobs
rake jobs:work
Rake DB Drop & Prime
rake db:drop db:create db:schema:load
rake db:dev:prime
PKPD
rake db:drop db:create db:schema:load
engines/pkpd/bin/simulate_deploy.sh
rake db:setup
Help
rake -T | grep prime
Rails Console
rails c
Content tag contact
content_tag :li, class: css_class do
link_to(text, path, name: name) +
link_to('', "javascipt:void(0)", class: "CLASSNAME")
end
Selenium Driver
Selenium Driver Config steps to test the feature/CSS styles layouts/JS features in action in Chrome browser: (This are just to see whats going in your spec)
Note: Please do not commit these configs
Add these to your application
Gemfile
within Test group:
gem "selenium-webdriver"
gem "chromedriver-helper"
Run
bundle install
in terminal.In
spec/rails_helper.rb
Comment out line 54Capybara.javascript_driver = :webkit
Add below code in
spec/rails_helper.rb
line 53:
Capybara.register_driver :selenium_chrome do |app|
Capybara::Selenium::Driver.new(app, :browser => :chrome)
end
Capybara.javascript_driver = :selenium_chrome
Run your individual feature spec and see them running in a new Chrome browser.
Adding Route
resources :tools do
collection do
get :run_now
end
end
<%= link_to t(".add_new_metadata_source"), run_now_study_tools_path(**@**study), remote: true, class: "”=%>
Checking available routes
# All
rake routes
# Search routes
rake routes | grep <routename>
Misc
rake tmp:clear
rails new projectname
bundle exec rails g controller home
Last updated