This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= form_for(@person) do |f| %> | |
<%= f.label :gender %> | |
<%= f.select :gender, options_for_select([["Male", true], ["Female", false]]) %> | |
<%-# in this case :gender is boolean -%> | |
<%= f.label :birthdate, "Birthday" %> | |
<%= f.date_select :birthdate, :start_year => 1940 %> | |
<%= f.submit "Submit" %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Sass CSS reset | |
// | |
html, body, div, span, applet, object, iframe, | |
h1, h2, h3, h4, h5, h6, p, blockquote, pre, | |
a, abbr, acronym, address, big, cite, code, | |
del, dfn, em, img, ins, kbd, q, s, samp, | |
small, strike, strong, sub, sup, tt, var, | |
b, u, i, center, | |
dl, dt, dd, ol, ul, li, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// layout file | |
<body> | |
<div class="container"> | |
<%= flash_messages %> | |
<%= yield %> | |
</div><!-- /container --> | |
</body> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% flash.each do |type, message| %> | |
<div class="alert <%= bootstrap_class_for(type) %> fade in"> | |
<button class="close" data-dismiss="alert">×</button> | |
<%= message %> | |
</div> | |
<% end %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
# Includes Authorization mechanism | |
include Pundit | |
# Prevent CSRF attacks by raising an exception. | |
# For APIs, you may want to use :null_session instead. | |
protect_from_forgery with: :exception | |
# Globally rescue Authorization Errors in controller. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe PersonPolicy do | |
subject { PersonPolicy } | |
let(:person) { create(:person) } | |
let(:user) { create(:valid_user) } | |
context 'given user\'s role activities' do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateRoles < ActiveRecord::Migration | |
def change | |
create_table :roles do |t| | |
t.string :activities, array: true, length: 30, using: 'gin', default: '{}' | |
t.timestamps | |
end | |
end | |
end | |
## |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def screenshot | |
require 'capybara/util/save_and_open_page' | |
now = Time.now | |
p = "/#{now.strftime('%Y-%m-%d-%H-%M-%S')}-#{rand}" | |
Capybara.save_page body, "#{p}.html" | |
path = Rails.root.join("#{Capybara.save_and_open_page_path}" "#{p}.png").to_s | |
page.driver.render path | |
Launchy.open path | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uk: | |
errors: | |
messages: | |
expired: "прострочено, створіть новий" | |
not_found: "не знайдено" | |
already_confirmed: "вже було підтверджено, спробуйте увійти" | |
not_locked: "не було заблоковано" | |
not_saved: | |
one: "Виникла помилка, через яку неможливо зберегти зміни:" | |
other: "Виникли помилки (загалом - %{count}), через які неможливо зберегти зміни:" |
OlderNewer