[:first, :second, :third].inject({}) { |hash, key|
hash[key] = self.send(key)
hash
...
Ruby Hash via injectin
def self.group_by_month(events) ...
Ruby AR help - return models gro...
Given an event with the fol...
<%= form_for :page, :url => { :action => :create } do |form| %>
<div class="tabs">
...
Ruby Rails Helper extraction
I want to make this thing m...
<% if controller.action_name == 'leerling' %> <%= link_to "Voortgezet", url_for(:vopo => "vo") -%> | <%= link_to "Basis", url_for(:vopo => "po") -%> <% end %> ...
Ruby If statement with or?
I want multiple conditions ...
module Menus def self.getValidPositiveNumber ...
Ruby Good way to output menu wit...
What would be the best or a...
class ProductsController < ApplicationController helper_method :sort_column, :sort_direction ...
Ruby Moving Code from Controller...
Hi all,
I know that the c...
module Menus class Main_Menu ...
Ruby Help with module?!
Hi Im working on a program ...
<% if I18n.locale == :pl %>
<%= link_to 'PL', { :locale => :pl }, :class => "language_selected" %> | <%= link_to 'ENG', { :locale => :en } %>
<% else %>
...
Ruby Language Selection
Hi, I'm sure this is the mo...
def format_category_list(sub_categories)
count = sub_categories.count
list = ""
...
Ruby Generating a list of 3 entr...
I have this function in my ...
def load_feeds #feed url po = 'http://feed.kennisnet.nl/Basisonderwijs' ...
Ruby Fetch and parse feeds with ...
Function to fetch and parse...
@cart = CartItem.sum(:quantity, :group => "cart_id") new_ids = [] @cart.each do |c| ...
Ruby Sum of the Column
What i want to do is, find ...
uri = URI.parse(the_uri) hash = CGI.parse(uri.query) hash["size"] = size.to_s ...
Ruby Set value of key in uri
Is there some magic i don't...
openid_mapping = {
:email => ["email", "http://axschema.org/contact/email"],
:name => ["fullname", "http://axschema.org/namePerson"]
...
Ruby Hash + Array refactor
This actually works but I w...
def images image = Kernel.const_get(params[:class].capitalize).find_by_link(params[:id]).image if image.nil? ...
Ruby Rails DB Field to Image Out...
This is a rails action that...
hash = {}
array.each { |key| hash[key] = func(key) }
Ruby How to make it more idiomatic?
Can you make this code more...
sum = 0
self.items.each { |item| sum += item.fragments.count }
...
Ruby Calculate sum of items in a...
I'm pretty sure I'm not doi...
class ItemsController < ApplicationController
def create
@product = Product.find(params[:product_id])
...
Ruby Add product to cart, reject...
I've a simple cart applicat...
class MessagesController < ApplicationController before_filter :require_user, :only => [:new, :edit, :destroy] before_filter :redirect_if_doesnt_exist, :only => [:show] ...
Ruby Ruby on Rails controller re...
What can be done to simplif...
if @user && @user.role && @user.role.eql?('user') && @user.user_group
@group_name = @user.user_group.name
end
Ruby Handling NoMethodError
It seems to me that there s...
// generate code for parsing an array of array tab = [ ["a","b"] , ["c","e"] , ["d"]] ...
Ruby Generate code for parsing a...
It's dirty but it's work...
# Array of LDAP group names @group_names = [] ...
Ruby Refactor array of hashes
The code below gives me wha...
def is_translated?
if !params[:lang].blank? and params[:lang].eq?('en')
return true
...
Ruby too many ifs and ands
there are too many if then ...
def include_class?(obj_class)
stack = []
...
Ruby hash.include_class?, recursive
I have a hash like this one...
class ModernWarfare2 < Challenge GAME_MODES = ['Capture the Flag', 'Demolition', 'Domination', 'Headquarters', 'Sabotage', 'Search and Destroy'] ...
Ruby List of randomized items fr...
I've removed the code that ...
if @user.valid?
....
result = create_customer
...
Ruby Redundant Else Clauses
Hi,
I have a controller wh...
Hi, how to simplify this:
...