I still learning Ruby on Rails, but have been wondering what happens if I make a mistake. For example, if I scaffold and make a typo, what do I do? If I don't do scaffolding, generate a model, rake db:migrate it and find out I need to ad a column or delete one, what do I do? Is it better sometimes to use a third party manager on the d...
So, I have this in my model:
# app/models/interior.rb
class Interior < ActiveRecord::Base
belongs_to :casa
has_attached_file :plano,
:path => ":rails_root/public/planos_unidades/:styles/:id.:content_type_extension",
:url => "/planos_unidades/:styles/:id.:content_type_extension",
:styles => { :thumb => '98x98' },
:co...
On my Linux box, what is the easiest way to allow another machine on the NAT to access a running mongrel server? (Rails 2.3)
This is for the purpose of browser compatibility checks.
...
While working on Rails 3 app, I came to the problem of nested forms.
One collection is a set of predefined objects (created with db:seed).
The other collection should show a form to allow to choose a few elements.
An example is better than a long description, so here it is.
Suppose you have 2 models: User and Group.
Suppose there are...
I'm a moderately competent Python programmer, and am considering working on my first web-app; it seems a very large number of FOSS webapp code is written in Ruby (i.e. Rails), and I suspect that might help with my learning curve (i.e. for building a decent, if useless webapp).
There is lots of material for learning Ruby on the interwebs...
A lot of my users keep going to http://(rails app URL)/blog, but I don't actually have a blog. I finally setup a Posterous blog and now want to direct my users there. Is there a way to configure this using routes.rb? Is there a better way that doesn't involve editing the httpd.conf file?
...
I've upgraded my app from using config.gem to a Gemfile with bundler and have noticed that my unit tests have now stopped running. It's a bit strange and I'm not entirely sure where to start looking.
When I run rake test:units --trace I can see my environment being setup and it lists the files it intends to execute, but then it just re...
Rails's script/server is just a few lines:
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/server'
I wonder where the server file is? I tried a
find . -name 'server.*'
find . -name 'server'
but can't find it
...
http://stackoverflow.com/questions/2823492/install-gem-from-github-branch
I have been following the guide from that thread. When I get to step 4, rake gem , I get an error
rake aborted!
Don't know how to build task 'gem'
...
This is for http://github.com/tobi/delayed_job
the example says:
script/generate delayed_job_migration
if I run it
$ script/generate delayed_job_migration
Couldn't find 'delayed_job_migration' generator
On github, there is a generators folder, an init.rb, a lib folder, and a tasks folder, where should they go into our project? (u...
I'm fairly new to both Ruby and Rails (using 2.3.8), so forgive me if I'm missing something really obvious here but I've been struggling with this for a while and my searches have been fruitless.
In my code I have Plans, and a Plan has many Plan_Steps. Each Plan_Step has a number (to indicate '1st', '2nd', etc). I have a form to update ...
I'm setting request.format = :mobile within an ApplicationController before_filter.
before_filter :some_filter
def some_filter
request.format = :mobile
end
I have this mapping in routes:
map.my_list '/my_list.:format', :controller => "of_no", :action => "significance"
When I do the following:
<%= link_to "My List", my_list_path...
I have the following code which displays instructions in an ordered list. When it's rendered in the browser, it outputs all of the instructions at the end in a single line. Am I doing something wrong? See output below for example.
Code:
<% @recipe.instructions.each_line do |instruction| %>
<li><%= instruction %></li>
<% end %>
Out...
I need to build an application that works like a mailing list. Instead of reinventing the wheel, I thought of using Mailman, DadaMail or GoogleGroups. But I need my Rails app to add and remove emails from these lists.
Any good rails plugins that you recommend?
...
Is there something similar to an after_filter that still runs if the action raises an exception?
I'm using an external logger (since I'm on Heroku); the response headers are filtered and logged in the after_filter. If an exception is raised, the filter doesn't run, and I don't have a log of the response header data.
If I try to hook i...
When I write
git push heroku master
my app is successfully pushed to heroku, but it takes about 30sec to a minute because it says it is "Installing gem rails 2.83" and that "Rails is not declared in either .gems or Gemfile."
How do I fix this? What exactly is the .gems file and where does it live?
Thanks a lot. I am completely new to ...
I have Rails 3, and have been using a Gemfile to install several gems like annotate and rspec-rails
Problem is in all the tutorials, it says to type things like "annotate" in the command line but it doesn't work "command not found" this make me believe that Symbolic Links are not in place to allow me to run/use the gems in terminal.
Ho...
I want to use fields_for on a subset of records in an association.
I have a Month model, which has_many :payments.
But in my form in my view I only want to have fields_for some of those payments. For example:
- fields_for @month.payments.large
This doesn't work.
Can I pass a set of records to fields_for, rather than the usual symbo...
Hi,
In remote_function how can i pass the className of the form element
i have the following code,
<%=link_to(content_tag('span',t('country.name')),'#',
{:title=>t('country.name'),**:class=>"change_list"**,
:onclick=>remote_function(:url => {:action => :change_view},
:with =>"'**change**=**'+ ?????"**)}) %>
so, on onclick...
If I'm using Instant Rails, how do I upgrade my Ruby version from 1.8.6 to 1.9.* which they say runs faster in Windows? What's the necessary Instant Rails console command? Thanks.
...