class Company has_many :stores end ...
Ruby Active Record getting uniqu...
>> %w(Pending Processing Executed Canceled).each_with_index.map {|v, i| i}
=> [0, 1, 2, 3]
Ruby Get array of indexes from g...
Using it :in validates_incl...
<%= link_to (image_tag("sign_up_button.png", :alt => "Sign up now!"), "sign_up_now!") %>
Ruby Center Image link
I need placed image-link on...
# chip away at the bonuses play through amounts
bet_through_credit_remaining = self.wager
self.user.bonuses.ranked.each do |bonus|
...
Ruby apply a credit over an orde...
example: if the credit is ...
def steps
unless @steps
if scenario.class == Cucumber::Ast::OutlineTable::ExampleRow
...
Ruby unless.. if..
These two methods both seem...
class Job has_many :tasks ...
Ruby Convert SQL scopes to somet...
Using Rails 3.0.10, and Pos...
.---.
| v*
.--------------.
...
Ruby Instance-level authorization
Is this database structur...
match '/:id', to: 'high_voltage/pages#show', as: :static, via: :get, ...
Ruby Rails route
High Voltage match :id base...
if @image.update_attributes params[:product_image]
if request.xhr?
render :json => { :status => 'success', :data => {:message => I18n.t('product_image.results.reordered')} }
...
Ruby DRY up a controller action
Any suggestions for DRYing ...
has_many :contactships
has_many :uers, :through => :contactships
...
Ruby CanCan through a join model
Is there a better way to lo...
def rating_stars(rating)
output = []
rating.round.times { output << content_tag(:span, "★", class: 'full') }
...
Ruby Generate span elements for ...
Is there a better/alternati...
class IsbnsController < ApplicationController before_filter :correct_user, :only => [:destroy, :edit, :show, :update, :index, :new, :create] before_filter :correct_user_admin, :only => [:destroy] ...
Ruby Horrific if/else nonsense i...
Posting for the comedy/shoc...
require 'active_support/core_ext' class Float ...
Ruby Humanizing currency
Looking for a more succinct...
def my_method
if session[:my_params].try(:include?, :answer)
session[:my_params][:answer]
...
Ruby Best way to refactor this p...
Hi,
I am quite new to Ra...
def shadow
content_tag :div, :class => 'b-shadow' do
result = ''
...
Ruby content_tag
There is any special helper...
composed_of :assistant_fee,
:class_name => "Money",
:mapping => [%w(assistant_fee_in_cents cents), %w(currency currency_as_string)],
...
Ruby Refactoring multiple compos...
I have a model that has sev...
<%= select_tag :editor_id, options_for_select(Member.where(:role => :editor).select {|m| m.authentications.count > 0 }.collect { |u| [u.name, u.id] } ) %
Ruby messy Rails select
any help appreciated!
<% if @job.new_record? %> <%= f.radio_button :environment_id, env.id, :checked => env.is_default %> <% else %> ...
Ruby radio select tag by default...
Is there a better way of do...
def search
@search = params[:company_search]
@results = Company.search @search, :include => :staff_id,
...
Ruby Messy if statements
This works but it's messy. ...
def notify_reply_by_email
if !self.user.disable_emails?
if self.root?
...
Ruby Notify by email
how can this be better done...
require 'open-uri' class NewsController < ApplicationController ...
Ruby Problem with passing xml fr...
Hi!
Im trying to parse xml...
STATES = ['address', 'shipping', 'receipt', 'confirmation'] def next_state! ...
Ruby Next Array Value
Trying to figure out a bett...
def self.find_for(options = {})
scope = scoped
scope = scope.where(:hook => options[:hook].to_s) if options[:hook]
...
Ruby ActiveRecord query construc...
Rails 3.0.3
This method ...
class CustomersController < ApplicationController #GET /customers #GET /salons/1/customers ...
Ruby Any further refactoring can...
@current_salon and @current...
def display_title
if @title.blank?
APP_CONFIG[:site][:title]
...
Ruby Page Title Display Helper
I have a helper that append...
I still think I could make ...