[:first, :second, :third].inject({}) { |hash, key|
hash[key] = self.send(key)
hash
...
Ruby Hash via injectin
<% 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 ...
def user_photo(user, values = {})
values[:style] ||= ''
values[:class] ||= ''
...
Ruby User thumbnail helper needs...
Bit of a Ruby noob. Could u...
<%= form_for :page, :url => { :action => :create } do |form| %>
<div class="tabs">
...
Ruby Rails Helper extraction
I want to make this thing m...
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...
hash = {}
array.each { |key| hash[key] = func(key) }
Ruby How to make it more idiomatic?
Can you make this code more...
@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 ...
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 ...
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...
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...
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...
<% 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 ...
if @user.valid?
....
result = create_customer
...
Ruby Redundant Else Clauses
Hi,
I have a controller wh...
module Menus class Main_Menu ...
Ruby Help with module?!
Hi Im working on a program ...
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...
class ItemsController < ApplicationController
def create
@product = Product.find(params[:product_id])
...
Ruby Add product to cart, reject...
I've a simple cart applicat...
def load_feeds #feed url po = 'http://feed.kennisnet.nl/Basisonderwijs' ...
Ruby Fetch and parse feeds with ...
Function to fetch and parse...
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...
def include_class?(obj_class)
stack = []
...
Ruby hash.include_class?, recursive
I have a hash like this one...
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...
# Array of LDAP group names @group_names = [] ...
Ruby Refactor array of hashes
The code below gives me wha...
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 ...
// 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...
Hi, how to simplify this:
...