I'm guessing all objects that are local to the action are passed into the view?
I never see sample code that actually specifies which objects are passed to the view!
Is it good practice to create a 'model' object and then assign, as properties to the 'model' object, all objects you want to pass to the view?
How can you explicitly pass...
Is installed this ruby on rails plugin for sortable paginated tables, but can't get it to work on related objects.
git://github.com/kovacs/sortable.git
http://javathehutt.blogspot.com/2009/06 … rails.html
In the example given based on the User class, using the associated Role class, there is a :table_heading of ['Role', 'role'], a :sort...
I just created a new gem (using bundler) and want to add Active Record support. So I added s.add_dependency "activerecord", "~> 3.0" to my gemspec. Then I use Bundler.setup and Bundler.require and thought that I have access to Active Record now, but I haven't. I have to explicitly use require "active_record". Any idea why Bunder.require ...
I have a Rails 2.2 app that I'm supporting and one thing that needs to be done before the app start is a small rake task to initialize and make sure the database is properly set. How can I get this task run right after rspec initializes the database. I run rspec using the rails spec command.
...
We're doing an upgrade to Rails 3 (like half the world right now), and I've been diligently replacing usages of RAILS_ENV eg
RAILS_ENV == 'wibble'
# becomes
Rails.env.wibble?
But I'm not as certain of what to do with:
ENV["RAILS_ENV"] ||= 'production'
We've got it at the top of a whole bunch of rake tasks and daemons... and the id...
Hello fellow developers,
I am trying to model a one-to-one association with my devise model and for some reason, I cannot access the edit path for the dependent model. Here is what I mean:
I have a CRUD controller for both a User and Credential model. User is a devise model.
class Credential < ActiveRecord::Base
belongs_to :user
end...
Hello! I'm using Rails 3, Uploadify, to send images to S3.
Right now all the images being upload have the MIME: application/octet-stream
I'd like to fix that but I'm getting the following error:
NoMethodError (undefined method `original_filename' for #<ActiveSupport::HashWithIndifferentAccess:0x107c81998>):
app/models/photo.rb:29:in...
Good day...
Still a beginner question. I mostly asking to save myself hours of trial and error... I had those already and there was no result.
What I wanna do... I have a controller that has an action, of course. I want to send this action two IDs, it should make some database entry of those. No problem, the action works well.
But I d...
I'm a newbie following the RailsTutorial.org program and have installed/setup rvm, ruby 1.9.2,rails, curl, git and created my first app and pushed it to github (so the SSH key is fine).
The next step is deploying to Heroku, which is killing me:
gem install Heroku
works fine but I get this error after "heroku keys:add" or "heroku crea...
I can do this in the controller to get the model class:
self.class.name.gsub("Controller", "").singularize.constantize
But is there a built in method for this in the controller?
Something like self.model_class?
Thanks!
...
I'm trying to deploy a rails app to Heroku and I'm running into some basic git problems. I'm new to this all -- rails, git, heroku -- so I'm afraid I'm getting lost on what's probably a fairly basic concept.
I've pushed the app to Heroku, but when I'm migrating the db ($ heroku rake db:migrate), I keep getting the following error:
rake...
I have a contact model, this includes name, address, phone number, etc.
I have a user model which should have_one contact.
I have a Customer model which has_many contacts.
I have a Producer model which has many contacts.
A contact can be only a user, a user and a customer, a user and a producer, or any combination of these three. I a...
I have a list of users that have requested access to my application.
They appear in a table inside a view:
<table>
<thead>
<th>Company</th>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>Role</th>
<th>Action</th>
</thead>
<% for ar in @brand.access_requests %>
...
Hi,
I have a country model and a places model - a country has_many places, and a place belongs_to a country. A place model also has_many posts (which belong_to a place). I would like to aggregate all the posts from places that belong to a certain country into a feed - rather like a friend activity feed on a social networking site. I'm h...
In ActiveRecord models you can specify custom SQL-request for has_many associations.
For example,
class User < AciveRecord::Base
has_many :events, :finder_sql => 'SELECT something complex'
end
While user.events returns what I need, the number of records returned can be huge, so I need to have a way to pass parameters for LIMIT. Is t...
I've been doing some cool stuff with rmagick on my rails app. I tried starting up my project with 'rails server' and I got this error. I believe I have imagemagick and rmagick installed so I don't know why I see this error.
/Users/devinross14/.gem/ruby/1.8/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `require': no ...
I'm building a Rails plugin that extracts a lot of data from Rails apps. It builds queries dynamically that span multiple tables, and there will be a lot of results returned. Here's an example of one of the queries built for pulling purchase data out of a Spree (Rails shopping cart):
select orders.user_id as from_id, variants.product_id...
Hello,
I have 3 models: user, wish_list and wishes:
user has_one wish_list
wish_list has_many wishes
On my index page, I'm listing all the wishes of my current_user's wish_list
in my controller's index method:
@list = current_user.list
@wish= @list.wishes.build
in my index view, I want to put a form to add a new wish on top ...
I'm writing a review system for items in Ruby on Rails. I want the process to be as follow:
users to start entering their review/ratings
when they hit submit, if they're not logged in, users are redirected to the signup or login page,
they create and account or signup
they're redirected to the post where they wrote a review, and the ...
THE SITUATION:
I have code in lib/foo/bar.rb with a simple method defined as such:
module Foo
class Bar
def test
"FooBar"
end
end
end
In my helper, FooBarHelper, I have:
require `lib/foo/bar`
module FooBarHelper
def test_foo_bar
fb = Foo::Bar.new
fb.test
end
end
In my view, I call this helper method li...