I have a model that I'm trying to retrieve an array of data from, and I don't need the data to be instantiated into Ruby objects. In fact, that just introduces an extra step into my code to step through the objects and generate a new array with just the data I need.
Example:
class Book
#has attribute in database title
end
I would ...
I am trying to build a Rails app with multiple models in a single form, and multiple forms on a single page. To make that work (according to my limited knowledge), I have to drop out of the scaffold code and the "form_for :model" helper and use "form_tag" instead. However when I do that, I lose the ability to automatically catch and repo...
When my project is growing up, I need to write some methods, but application_controller's private methods and helpers aren't provide enough space to store all extensions.
So I have looked at custom classes and methods, which are stored in the /lib folder.
But i still have some questions, which i can't solve:
-When should I use "class ...
I'm working on a Rails app and using the restful-authentication plugin. The app will include user images. Only users who log in will be able to browse, but I wondered if I can also restrict direct URL access to the images to only allow logged-in users.
In other words, even if you know that an image is at thesite.com/user1/foo.jpg, you c...
Hi,
it's about Ruby On Rails and it's Restful Authentication plugin.
The title says it all:
I updated Rails.
I restarted my WebApp.
The method "store_location" of Restful
Authentication cannot be found. in the
file lib/restful_authentication.rb can
the method be found, by me, but no
longer by Rails.
Why?
Please help!
Yo...
Hi,
it's about Ruby On Rails.
I want to use Googleauth and need to add a line starting with "config.gem" in the Rails:Initializers block in the environment.rb. Sadly, Passenger tells me that this would be an unkown command.
config.gem "googlebase", :lib => 'google/base', :version => '0.2'
What do I have to change to get, possibly be...
There are currently two problems with storing ActiveRecord objects in memcached.
The Undefined Class/Module problem (Google search). From what I've read up, this is still a bug that nobody has a real good solution for. The cache_fu plugin has probably the best solution for this, wrapping its retrieve call in a block that tries to catc...
I have three models:
class Book < ActiveRecord::Base
has_many :collections
has_many :users, :through => :collections
end
class User < ActiveRecord::Base
has_many :collections
has_many :books, :through => :collections
end
class Collection < ActiveRecord::Base
belongs_to :book
belongs_to :user
end
I'm trying to display a l...
I have a RoR project on my Windows 7 PC.
I want to create some Ruby code that I can execute from the cmd.exe command line that manipulates the development database (via database.yml) of the project. (I don't want to have to run my utility code via a web page.)
What is the best way to go about pulling this off? (I'm a newbie.)
I can'...
This code runs on my local RoR/Windows 7 (64-bit):
sql = ActiveRecord::Base.connection()
last_pk = sql.insert("insert into manual (name) values ('hello new value')")
puts 'last_pk=', last_pk
but always displays "0."
For various reasons I can't use ActiveRecord in this situation.
(Note: The above code runs fine on my shared host.
A...
I’m trying to use a UUID as the primary key for a Rails app, and am running into problem after problem.
I am specifying in migration this:
create_table :users, :id => false do |t|
then this:
execute("ALTER TABLE users ADD PRIMARY KEY(uuid)")
In my user model:
set_primary_key "uuid"
Using the UUID tools to generate the UUID....
Something I've always wondered about rails is the ability to pass extra data to find_or_create methods in rails. For example, I can't do the following
User.find_or_create_by_name('ceilingfish', :email => '[email protected]', :legs => true, :face => false)
I could do
u = User.find_or_create_by_name('ceilingfish')
u.update_attributes(...
I have three models:
class Address < ActiveRecord::Base
has_many :jobs
end
class Category < ActiveRecord::Base
has_many :jobs, :dependent => :destroy
end
class Job < ActiveRecord::Base
belongs_to :category
belongs_to :address
end
I'm trying to get all categories that the jobs has address_id != NULL
I'm almost there doing:
cate...
I have a set of columns that applies to more than 1 model.
For the sake of discussion, it could be:
User has many Addresses
Company has an Address
These are separate models, but the Address columns will be identical between the 2.
What's the best way to accomplish this in Rails?
...
Currently I can only get the default nginx page to come up on my domain name. I am pretty sure the error is either in the /etc/hosts file or the enginx.config file.
my /etc/hosts file is
127.0.0.1 localhost.localdomain localhost
myip server.mydomain.com server
and nginx.config is:
server {
listen 80;
...
I setup my rails project "tracks" using:
$ rails --database=mysql tracks # OK
$ cd tracks
$ vim config/database.yml # correct using mysql adapter, added password spec
$ rake db:create RAILS_ENV='development' # OK
$ rake db:migrate # OK
$ ruby script/generate scaffold user name:string password:string email:string url:string # OK
$ rake ...
I've just upgraded from MRI-1.8.7 to MRI-1.9.1 and heard about this lighthouse ticket which indicates that Ruby 1.9.1 and Rails 2.3.x won't play nicely together when a user enters any kind of non-ASCII standard character (i.e. å é Ã Ø å ल) unless rails is patched.
My problem is that I CAN'T reproduce the bug.
I've tried everything. I'...
I iterate over an array of CartItem class I created and populate a view file.
<td><%= button_to "remove", :action => :remove_from_cart, :id => cart_item %></td>
I would like to be able to get a CartItem instance from params[:id] in the remove_from_cart.
param[:id] returns something like "#<CartItem:0xb77a3dcc>":String and i could not...
Hi,
I'm new to RubyAmf. I noticed that you can send an object with RubyAmf as follows:
format.amf { render :amf => @user}
Which works fine. But I wasn't sure what to do what when I have two ,or more, objects:
@projects = @user.projects
@tasks = @user.tasks
How can I can send @projects and @tasks without having to do multiple reque...
I have a rails module included for reference below that I have included using "require 'model_helper' at the bottom of my environment.rb file.
Everything works fine in development, but when I deploy to my nginx/passenger production environment I get an error that the method acts_as_notifiable defined in my model_helper is not found. ...