Skip to content

Instantly share code, notes, and snippets.

View Fire-Dragon-DoL's full-sized avatar

Francesco Belladonna Fire-Dragon-DoL

View GitHub Profile
@Fire-Dragon-DoL
Fire-Dragon-DoL / models.rb
Last active December 14, 2015 04:09
Boat tech specs different for each locale
class Boat < ActiveRecord::Base
validates :name, presence: true, uniqueness: { case_sensitive: false }
has_many :tech_specs, order: 'position'
def visible?
self.visible
end
end
@Fire-Dragon-DoL
Fire-Dragon-DoL / form.html.erb
Created March 3, 2013 17:43
Simple form to choose which translation should be edited
<%= form_tag([:edit, :admin, @tech_spec.boat, @tech_spec], method: :get) do %>
<%= select_tag(:translation,
options_from_collection_for_select(@translations,
:first,
:last,
@translation)) %>
<%= submit_tag('Go to this translation') %>
<% end %>
doctype html
html lang==I18n.locale
head
meta http-equiv="X-UA-Compatible" content="IE=edge"
meta charset="utf-8"
meta name="viewport" content="width=device-width, initial-scale=1.0"
title
= yield :title
| | Austin Parker
= yield :top_head
a.button-icon
{
$button-icon-width: image-width('layouts/client/boat-button.png');
$button-icon-height: image-height('layouts/client/boat-button.png');
margin: 0;
padding: 0;
width: $button-icon-width;
height: $button-icon-height;
color: $grayLight;
span { font-size: 14px; }
doctype html
html lang==I18n.locale
head
meta http-equiv="X-UA-Compatible" content="IE=edge"
meta charset="utf-8"
meta name="viewport" content="width=device-width, initial-scale=1.0"
title
= yield :title
| | Austin Parker
= yield :top_head
@Fire-Dragon-DoL
Fire-Dragon-DoL / action_controller.rb
Created March 14, 2013 23:49
How to set default_url_options?
module PrefixRoutesWithLocale
module ActionController
module BaseMethods
def self.included(base)
base.send :prepend_before_filter, :set_locale_from_prefix_or_suppose
end
protected
@Fire-Dragon-DoL
Fire-Dragon-DoL / action_controller.rb
Created March 15, 2013 01:23
How I am replacing default_url_options method
module PrefixRoutesWithLocale
module ActionController
module BaseMethods
def default_url_options
self.prefix_routes_with_locale_default_url_options.merge({locale: I18n.locale})
end
end
end
@Fire-Dragon-DoL
Fire-Dragon-DoL / Error
Last active December 15, 2015 01:08
Why factory girl can't find short_description= ?
1) Boat when logged in as admin GET /admin/boats displays boats
Screenshot: /mnt/hgfs/d_wamp_www/austin/austinparker_it/tmp/capybara/screenshot_2013-03-16-18-09-16.391.png
Failure/Error: boat = FactoryGirl.create(:boat)
NoMethodError:
undefined method `short_description=' for #<Boat:0x00000006965f40>
# ./spec/features/boats_spec.rb:14:in `block (4 levels) in <top (required)>'
a.button-icon:hover > div, .button-icon.inactive > div
{
// background-image: image-url('layouts/client/boat-button-hover.png');
@include background-image(linear-gradient(bottom,
rgba(153,204,255,.93),
#181818));
background-image: -ms-linear-gradient(bottom, rgba(153,204,255,.93), #181818);
color: $blueLight;
}
@Fire-Dragon-DoL
Fire-Dragon-DoL / Errors.txt
Last active December 15, 2015 01:19
Boat visible can be...
Failures:
1) Boat visible can be if there are less than 7 boats visible
Screenshot: /mnt/hgfs/d_wamp_www/austin/austinparker_it/tmp/capybara/screenshot_2013-03-17-01-43-15.348.png
Failure/Error: FactoryGirl.create(:boat).should be_valid
expected #<Boat id: 8, name: "Jarrod", created_at: "2013-03-17 00:43:15", updated_at: "2013-03-17 00:43:15", visible: true, short_description: "Velit eligendi sint voluptatem temporibus est fugit...", description: "Cupiditate maiores voluptatem quibusdam. Inventore ..."> to be valid, but got errors: Visible slots available only if visible? There are already 7 over 7
# ./spec/models/boat_spec.rb:62:in `block (3 levels) in <top (required)>'
Finished in 1.92 seconds
10 examples, 1 failure