Hi,
I would like to "cap" a number in ruby (on rails).
For instance I have has a result of a function a float but I need an int.
I have very specific instructions, here are examples:
if I get 1.5 I want 2
if but if I get 2.0 I want 2 (and not 3)
so doing number.round(0) + 1 it won't work.
I could write this function but, I sure it a...
script/generate became very annoying since i started using rspec etc. i dont need unit test files and fixtures anymore, but script/generate makes them anyway.
is it possible to set --skip-fixtures and --skip-test to be default system-wide (or at least project-wide)?
...
This is probably a silly question but if you use ActiveMerchant (or spree), do the creators of ActiveMerchant (or spree) take a commission? Since it's open source I wouldn't expect them to. But at the same time, because it's such a large undertaking to create a processing gateway, it would not surprise me if they wanted some compensation...
I have nginx with rewriting working correctly on my server in production.
But when I tried to set the same rule on my local development machine (mac) the rewrite doesn't seem to be working.
I want "universitytutor.local" to redirect to "www.universitytutor.local"
Here is the relevant part of my nginx.conf
server{
listen 80;...
I'm attempting, poorly, to implement an achievement system into my Ruby on Rails application.
I have a long list of achievements I'd like to check for. All are triggered by some create action in various controllers.
I've had the idea that I'll have a achievement model, which includes the controller and action it responds to. Then do ...
I find myself repeatedly looking for a clear definition of the differences of nil?, blank?, and empty? in Ruby on Rails. Here's the closest I've come:
blank? objects are false, empty, or a whitespace string. For example, "", " ", nil, [], and {} are blank.
nil? objects are instances of NilClass.
empty? objects are class-specific, and...
I'm working on something like a social networking mesh; I am using different API's from various websites, e.g. Last.FM, Delicious, Twitter, ...
I've created one controller per each website (currently, there are 7).
Sample views:
localhost:3000/lastfm <- All datas i gathered from user's Last.fm account
localhost:3000/twitter <- All da...
I want the sign up form on my site to have a field that takes the sum of a math equation and use rails validation to validate it. Whats the best way to do it?
i.e
What is 6 + 9 ? [ 8 ]
Error Message : You have entered the wrong number
...
I have a form that has been split out into a partial so I can use it both in the new view and the edit view. I have several dropdowns(selects) that are populated from a static array generated in a model.
In location model:
def open_close_times
@times = '','12:00 AM', '12:30 AM', '1:00 AM', '1:30 AM', '2:00 AM', '2:30 AM', '3:00 AM',...
I am working on re-writing my application based on things that I learned at RailsConf 2009. I understand that the Model, Controller and View relate to each other. However, one thing that I have struggled with is the "proper" level for a controller.
If the Rails Model maps (roughly) to a database table...
And if the Rails View maps (roug...
I have a Ruby on Rails page to edit a users profile. The form displays the user name and email correctly. When I change the name in the text box and click update I end up back at the edit_profile page with the message 'Profile was successfully updated.'. The problem is the value I changed the name to did not save to the database.
There...
Is there a way to update Rails in a pc without internet connection?
It has Windows XP, if that matter.
...
If you use Google Checkout, do you still need to use ActiveMerchant/Spree/some payment gateway or does Google act as the gateway the same way that ActiveMerchant/Spree would?
Also, are there any disadvantages to using Google Checkout that might be solved by using ActiveMerchant?
Also, is it a good idea to offer PayPal in addition to Go...
This is a follow up to this question. During development I have to restart the rails app everytime I change the code in lib/ in order for the code changes to take effect. How do I get this code to automatically reload like controllers, models, etc?
...
I tried applying the :maxlenght => 40 on a textarea on my form.
But it didn't work out.
Can we have a length limit on a textarea?
The code for text area is
<%= f.text_area :data,
:rows => 2,
:cols => 60 ,
:maxlength => 140,
:autocomplete => :off,
:class => ...
I am constantly seeing the following postgres errors/warnings in my Rails development log. It's not causing my app to fail (I hope). Any idea what could be causing them? What can I do to debug this?
Installed in my PC:
- Ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]
- Rails 2.2.2
- PostgreSQL 8.3.7
[4;36;1mSQL (0.1ms)[0m [0...
I had trouble using InnoDB MySQL 5.0 on OS X because of a my.cnf settings issue. Listing the gotchas in case it helps anyone:
If InnoDB is disabled, check the error log (hostname.err, in the data directory). I had an empty setting which I changed:
innodb_data_file_path = ibdata1:10M:autoextend
Hope this helps someone. I was running ...
Hi Stack Overflow Community!
I have the problem, that I have an migration in Rails that sets up a default setting for a column, like this example:
def self.up
add_column :column_name, :bought_at, :datetime, :default => Time.now
end
Suppose, I like to drop that default settings in a later migration, how do I do that with using rails...
I've just updated to Rails 2.3.2 from Rails 2.1 and noticed an issue with regards to using the :disabled option on input fields.
Previously we were using this option as a boolean, so we would indicate whether or not we wanted to disable the fields based on a method on the object, e.g.
f.text_field :amount, :disabled => @my_object.is_di...
How do I line up textfields so they look more neat? At the moment I've got:
<div id="content">
<h2>Change password</h2>
<% form_tag({:action => "change_password"}, :method => "post") do %>
<%= @error %>
<div class="form_row">
<label for="current_password">Current password:</label>
<%= password_field_tag 'curre...