I have Ruby versions 1.8.7 and 1.9.1 on Ubuntu.
How do I get the system to register Ruby 1.9.1 when using ruby -v?
ruby is at /usr/bin/ruby
ruby1.9.1 is at /usr/bin/ruby1.9.1
Also, can someone recommend a free text editor for Ubuntu?
...
Hi,
Can someone please translate this into manageable steps I need to take:
~ Wayne
You must now finish the install manually:
1) Place the folowing line at the end of your shell's loading files(.bashrc or .bash_profile for bash and .zshrc for zsh), after all path/variable settings:
[[ -s $HOME/.rvm/scripts/rvm ]] && source $HOME...
Given a search string "cars 'cats and dogs' fish 'hammers'", what's the best regex for capturing all search terms. It should support single and double quotes. A Ruby friendly answer if possible.
...
I'm creating dummy data for an app, and want to simulate exponential growth while also knowing the final number. So here's the proposal:
Given T = 2000. Total number of "counts" an event will have occurred.
And N = 7. Days of the week: 7.days.ago.day..Time.now.day.
What is the simplest formula for dividing T by N such that we create...
What is the exist status of a process opened with open() e.g.:
f = open("|#{cmd}", 'r')
while char = f.getc
do something ...
end
f.????
...
RoR newbie here. Working the "play time" exercises at the end of Agile Web Dev with Rails, chapter 9. Can't get link_to_remote to generate a link for me in a partial. My store_cart_item.html.erb partial looks like this:
<% if cart_item == @current_item then %>
<tr id="current_item">
<% else %>
<tr>
<% end %>
<td>
<!-- stuck her...
are there any tools which would read a data model exposed via ActiveRecord and generate equivalent data model using JPA?
note: We don't have any experience with ruby
...
I'm new at cucumber and capybara so maybe this is easy.
I'm using headers to check if a user is logged in or not and i'm having a problem when doing cucumber testing.
I use Capybara and Cucumber and a "add headers hack": http://aflatter.de/2010/06/testing-headers-and-ssl-with-cucumber-and-capybara/
The problem I have is that it only ...
For Example, I want to know the User have how many post. So, I do it in this way;
user.posts.length
It works, but when I see the server log, it shows me that:
SELECT * FROM "posts" WHERE ("posts".user_id = 6)
actually, I need to know the post number only, how can I do this? Thank you.
...
hey i played around with bundler and some gems and now i can't use rake anymore
if i do a simple db:migrate i get this error:
mac:app antpaw$ rake db:migrate
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:335:in `bin_path': can't find executable rake for rake-0.8.7 (Gem::Exception)
from <internal:gem_prelude>:282:in `method_missing'...
Hi Guys,
quick question.
If I type in my console
u = User.first
u.friends(&map:username)
I geht ["Peter", "Mary", "Jane"]
But I also want to show the birthday, so how do I do that?
u.friends(&map:username, &map:birthday)
doesn't work
thanks in advance
...
I'm using dm-observer to observe my dm models, and I need to perform some actions based on state changes within the model. I've figured out that @state is used to store the updated state value, but I have not been able to figure out how to access the old state value. In the example below I've used "old_state", but obviously that does not...
I have the following code:
@posts = Post.joins(:user).joins(:blog).select
which is meant to find all posts and return them and the associated users and blogs.
However, users are optional which means that the INNER JOIN that :joins generates is not returning lots of records.
How do I use this to generate a LEFT OUTER join instead?
...
Hi folks, I need to access a controller level action from another action. This is accessed by the view (so need authenticity token)
def post_message
#creates the message
#normally accessed via webform with authenticity token
end
def post_via_email
#my virtual mailserver calls this method when it receives an email
#i need to cal...
how to check the current status of server(up/down) from my rails application . If server become down,and many users are logined, I need to perform some actions.
...
Rails does model loading on demand. For a rake task that I'm writing, I need to be able to iterate over all ActiveRecord::Base instances (which is possible with ActiveRecord::Base.send(:subclasses)).
However, for the above to work, they have to already be loaded. Anyone know of a way to force all models to load? Ideally I'd like to n...
I want to test the age of a user of my Rails application using cucumber. The feature definition look somewhat like following.
Scenario: Successful calculation of age
Given I set my date of birth to "1987-07-15"
Then my age should be "22"
Above feature definition will fail every year since the age of user will increase by one each ...
I have a constraint and a validation placed on the guid field so that each is unique. The problem is, with the factory definition that I have below, I can create only one user instance, as additional instances fail validation.
How do I do this correctly so that the guid field is always unique?
Factory.define(:user) do |u|
u.guid UU...
how to dispose an object in ruby...?
class Designer
def message
"Hello, World!"
end
end
c = Designer.new
c.dispose # this is not working... any idea... or any alternative...?
thnx...
...
module Hints
module Designer
def message
"Hello, World!"
end
end
end
p Hints::Designer.message
Why this give me the following error...?
undefined method `message' for Hints::Designer:Module (NoMethodError)
...