config.authenticate_with do
warden.authenticate!
end
config.authorize_with do
redirect_to main_app.root_path unless current_user.has_role?(:admin)
end
= simple_form_for @time_slot, url: booking_path, method: :patch do |f|
= f.input :start_time, :as => :datetime, :minute_step => 30, :include_seconds => true, :discard_year => true, :datetime_separator => ' — ', :time_separator => ' - '
= f.input :id, as: :hidden
= f.submit "Book this slot", class: 'btn'
get gemset list
rvm gemset list
empty gemset
rvm getmset empty [gemset_name]
Heroku Mailer (SendGrid) configuration steps
-
Go to your heroku application.
-
Add SendGrid addons
-
Config STMP settings to your config/environment.rb
ActionMailer::Base.smtp_settings = {
User.where(:role => :admin).order(:username).pluck(:email) #=> [[email protected], [email protected]]
In your logged_in_controller.rb
class LoggedInController < ApplicationController
before_filter :authenticate_user!
end
In your logged_in_controller_spec.rb
Rails Admin field configuration
rails_admin do
list do
field :customfield do
def value
bindings[:object].your_method
end
end
end
class UrlValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
record.errors[attribute] << (options[:message] || "must be a valid URL") unless url_valid?(value)
end
# a URL may be technically well-formed but may
# not actually be valid, so this checks for both.
def url_valid?(url)
url = URI.parse(url) rescue false
##Capybara - Wait for ajax to complete
def wait_for_ajax
Timeout.timeout(Capybara.default_wait_time) do
loop do
active = page.evaluate_script('jQuery.active')
break if active == 0
end
end
The markup
<div id="parent">
<a id="child">Click here please</a>
</div>
Instead of binding event this way this way