upate table_name set position = position + 1 where position >= 5
2.3.1 :001 > ->() { false }
=> #<Proc:0x00000001f744e0@(irb):1 (lambda)>
2.3.1 :002 > !(->() { false })
=> false
Model1.includes(:model2).map { |item| item.model2.name }.uniq.each { ... }
Model1.includes(:model2).uniq { |item| item.model2.name }.each { ... }
class Article < ...
# ...
def to_param
"#{created_at.year}/#{created_at.month}/#{created_at.day}/#{transliterated_title}"
end
# ..
end
def to_param
"#{created_at.year}/#{created_at.month}/#{created_at.day}/#{id}-#{transliterated_title}"
end
def to_param
"#{created_at.year}/#{created_at.month}/#{created_at.day}/#{transliterated_title}-#{id}"
end
before_save :update_slug
private
def update_slug
self.slug = to_param
end
def to_param
"#{id}-#{transliterated_title}"
end
@resource = Article.find params[:id].to_i
scenario "root page" do
visit root_path
puts 'A'
expect(page).to have_link("Login", href: login_path(locale: I18n.locale))
puts 'B'
expect(page).to have_link("Signup", href: signup_path(locale: I18n.locale))
puts 'C'
end
module A1
TEST = 'zz'
end
module A1
class B1
def foo
TEST
end
end
end
module A2
TEST = 'zz'
end
class A2::B2
def foo
TEST
end
end
A1::B1.new.foo #> "zz"
A2::B2.new.foo #> NameError: uninitialized constant A2::B2::TEST
let(:confirm_oauth) { double deliver_now: nil }
before do
allow(ConfirmOauth).to receive(:email_confirmation)
.and_return confirm_oauth
end
subject! { do_something_that_calls_mailer }
it do
expect(ConfirmOauth).to have_received(:email_confirmation).with user
expect(confirm_oauth).to have_received :deliver_now
end
class Manage::SomeController < ...
layout 'manage_application'
end
# Disable Rails's static asset server (Apache or nginx will already do this)
config.serve_static_files = false
rescue_from ActionController::RoutingError, with: :routing_error
Post
.where.not(id: @posts_hot.map(&:id))
.where.not(id: Post.where(post_block_id: 2)) # magic number anipattern. лучше заменить на константу
.where.not(id: Post.joins(:post_asset).where.not(post_asset: { quote: nil }))
.order(created_at: :desc)
.limit(15)
Post
.includes(:post_asset)
.where.not(id: @posts_hot.map(&:id))
.order(created_at: :desc)
.limit(15)
.select { |post| post.post_block_id != 2 }
.select { |post| post.post_asset.try :quote }
$(document).on('page:before-change', function() {
window.turbolinks_referer = location.href;
});
$(document).on('page:load', function() {
if (window.turbolinks_referer) {
// yandex metrika
if (window.yaCounter7915231) {
window.yaCounter7915231.hit(location.href, $('title').html(), window.turbolinks_referer);
}
// google analytics
if (window.ga) {
window.ga('send', 'pageview');
}
}
});
rails s
выполнило не запуск сервера, а создание нового проекта.\curl -L https://get.rvm.io | bash -s stable
rvm install ruby-2.0.0-p247
)rvm use ruby-2.0.0-p247
gem install rails
cd /mnt/hgfs/github/rin
bundle install
rails server
теперь должна отработать