Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 2780

Ruby on Rails is an open-source web development framework written in Ruby. If your question code is written in Ruby on Rails, tag with Ruby as the language tag. Many things are defined by convention, freeing you from having to re-invent things to stay productive.

2 votes
1 answer
242 views

ruby code case when not so dry

Ruby code below seems to be not so dry. Can you please help me reduce the code. self.value = case self.type when 'fast' Increment.first.max_hours * Incrementor.first.fast_completion_day when 'super …
Prabesh Shrestha's user avatar
7 votes
1 answer
418 views

using method missing to reduce the code in ruby

I have a set of Class methods which is : class << self def increment_value self.first.increment_value end def max_work_hours_per_day self.first.max_work_hours_per_day end def fast_completion_da …
Prabesh Shrestha's user avatar
5 votes
4 answers
485 views

Fabricate with work dates

I am using code like this everywhere. How can I reduce such this code so that my Ruby code looks a lot cleaner? Fabricate(:tl, :when =>Date.yesterday.to_s,:work => 266,:type => "fast" ) Fabricate(:tl …
Prabesh Shrestha's user avatar
6 votes
Accepted

Fabricate with work dates

I found that I can use hash({}).each method to dry up the code. It is : {"fast"=>266, "super_fast" => 100, "ludicrous" => 50, "budget" => 900}.each{ |key, value| Fabricate(:tl, :when =>Date.yesterd …
Prabesh Shrestha's user avatar