This file contains 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
shared_examples_for "model with attributes" do |model_name| | |
context "validations" do | |
context "with valid values" do | |
let(:attributes) { attributes_for model_name } | |
let(:model_object) { build model_name, attributes } | |
subject { model_object } |
This file contains 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
# Remove all debug gems from your Gemfile and add | |
gem 'pry-remote' | |
# instead add interruption with debugger use | |
binding.remote_pry | |
# Use pry-remote in console and debug as you wish |
This file contains 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
There's an issue on globalize when adding or removing fields from the translations that causes the original migrations don't work properly (https://github.com/svenfuchs/globalize3/issues/131). | |
In my example I have a post model whih I create with some translated fields: name, slug and body. Some days later, I realise I need an excerpt field with a summarized version of the post and it has to be translated, so I create a migration to add this field. | |
Unfortunately, when you create the translation table it takes not only the fields you set in the params (:name => :string, :slug => :string, :body => :text) but also the params specified to the translates method in the model (:excerpt included) and creates a column for each one of those. | |
Solution here is to overwrite the translated attribute names of the class in the migration, so when you execute a migration you know which translated attributes will be declared and not need to worry about attributes that are not declared when you create the migration. | |
Overwriti |
This file contains 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
before_exec do |server| | |
ENV["BUNDLE_GEMFILE"] = "/var/www/proyectname/current/Gemfile" | |
end |
This file contains 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
# app/controllers/users/password_controller.rb | |
class Users::PasswordsController < Devise::PasswordsController | |
def resource_params | |
params.require(:user).permit(:email, :password, :password_confirmation) | |
end | |
private :resource_params | |
end |
This file contains 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
rake refinery:override javascript=admin | |
admin.js | |
if (typeof(custom_wymeditor_boot_options) == "undefined") { | |
custom_wymeditor_boot_options = { | |
classesItems: [ | |
{name: 'text-align', rules:[{name: 'left', title: '{Left}'}, {name: 'center', title: '{Center}'}, {name: 'right', title: '{Right}'}, {name: 'justify', title: '{Justify}'}], join: '-', title: '{Text_Align}'} | |
, {name: 'image-align', rules:[{name: 'left', title: '{Left}'}, {name: 'right', title: '{Right}'}], join: '-', title: '{Image_Align}'} | |
, {name: 'font-size', rules:[{name: 'small', title: '{Small}'}, {name: 'normal', title: '{Normal}'}, {name: 'large', title: '{Large}'}], join: '-', title: '{Font_Size}'} |
This file contains 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').validate({ | |
errorPlacement: function(error, element) { | |
if (element[0].tagName == "SELECT") { | |
element.parent().addClass('error'); | |
} | |
return true; | |
}, | |
unhighlight: function(element, errorClass, validClass) { |
This file contains 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
# somewhere in your middleware stack... | |
# request.env['yourapp.someid'] = "1337" | |
YourApp::Application.configure do | |
config.log_tags = [ | |
-> request { | |
request.env['yourapp.someid'] | |
} | |
] | |
end |
This file contains 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
#!/usr/bin/env ruby | |
# Put this file in the root of your Rails project, | |
# then run it to output the SQL needed to change all | |
# your tables and columns to the same character set | |
# and collation. | |
# | |
# > ruby character_set_and_collation.rb | |
DATABASE = '' |
This file contains 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
#!/usr/bin/env ruby | |
# So you want to start developing an already "woking" project. No | |
# bundle, config.gem's not present or messing up dependencies. Fear | |
# not! | |
# Do a "gem list" wherever the project is already working | |
# (production?, some colleage machine?). Make a file with this format: | |
# | |
# chronic (0.2.3) | |
# colored (1.1) |