Hello,
I am trying to understand has_one relationship in ruby on rails.
let's say I have two models - Person and Cell
class Person < ActiveRecord::Base
has_one : cell
end
class Cell < ActiveRecord::Base
belongs_to : person
end
can I just use has_one: person instead of belongs_to : person in Cell model?
isn't it same?
...
If you have DB columns created_at and updated_at Rails will automatically set those values when you create and update a model object. Is there a way to save the model without touching those columns?
I am bringing in some legacy data and I would like to set those values from the corresponding values in the (differently named) legacy data...
Hi, you have mention about how to store files in database.
How to attach those files with mail using action mailer?
I have search many sites but not able to find the way to attach database files.
Everywhere the help of attaching files stored in file system is given.
...
What is this?
"#{h params[:chat_input]}"
I am referring to the hash # and the h.
...
Hi All,
I have methods in all of my models that look like this:
def formatted_start_date
start_date ? start_date.to_s(:date) : nil
end
I would like to have something that automatically writes a method like this for each datetime field in each model, what's the best way to do this?
-C
...
I want to include
validates_confirmation_of :password
in a module but i keep getting errors like:
"undefined method `validates_confirmation_of' for Password::ClassMethods:Module"
Not sure how I can make it work.
thanks
...
After making a div draggable, i would like, when the div is dropped, to pass to the controller the div's position so that it can be saved on to the database.
My first idea would be to have an hidden form within the div, with 2 text fields (one for X and one for Y) which is kept updated via javascript and submitted on drop.
However this...
My application needs to provide the same data in XML to 2 different providers that have specific formatting requests.
What's the best way to setup my routes so that I can have the following:
http://www.site.com/posts/provider1.xml
http://www.site.com/posts/provider2.xml
(Where provider 1 and 2 are separate templates)
Thanks.
...
So my background is in Java web services, but I'm trying to make the move to ROR.
I'm using FlexImage to handle image uploading and thumbnail generation. I followed the guide and CRUD behavior was working fine at one point. However, at some point, CRUD behavior for one of my models (Images) was broken.
The error code I'm getting back...
I have a regular signup form with virtual_attributes:
attr_accessor :password_confirmation
def password
@password
end
def password=(password)
@password=self.crypted_password = User.encrypt(@password=pass, create_new_password_salt)
end
I would like to clear the password fields of the form when there are errors on password. I figu...
Looking around the web I see a number of plugins and patterns for using memcached in rails. I'm working on a new project and am wondering what the best of breed solutions are. Google turns up a lot of older results, which I'm not sure are the latest and best ways of doing things.
...
I am using "acts_as_nested_set" in my rails app. (extended with awesome nested set plugin). I was trying to logic out the best way to write a function/method to clone an element and its entire nested set so that each element gets a clone but the relationship structure mimicks the original, just with the new elements.
With nested sets y...
I'm trying to use the ssl requirement plugin with the restful authentication plugin and I have a question that I'm having trouble finding the answer to.
When allowing a user to login from a non-SSL action/page, should I require SSL on the session's create action for increased security, or is that overkill?
If so, how do I get the creat...
Yo,
I've got attachment_fu set up on my server, and it works just fine. My goal, however, is to be able to upload PDFs and have them convert to image (then use all the pre-built attachment_fu options like resize and thumb produce the desired images). What currently happens is that PDFs upload and remain PDFs, whereas images go through a...
I started writing functional tests for my rails app today. I use the RESTful authentication plugin. I ran into a couple confusing things I hope someone can clarify for me.
1) I wrote a quick login function because most of the functions in my rails app require authentication.
def login_as(user)
@request.session[:user_id] = user ? u...
I was using an earlier version of geokit plugin on a rails 2.3 app and just updated to this latest version - the one that now uses a gem.
In the previous version it was possible to convert the object returned by the .geocode method to json. by just calling the to_json method on it.
This however breaks in the new version.
I noticed the...
If I want to generate a random string for a token in rails, can I use validates_uniqueness_of on it? Given that this isn't something a user will input or get an error back for it needs to be unique straight away. Or am I just being stupid?
...
I was wondering what are the options for doing site analytics with a ruby on rails application ?
I haven't seen any solutions specifically targeted towards rails - more towards apache type web servers. I don't want to use the google analytics, I'd like to have the logging/analyis all local.
After a quick look at wiki's list of web analyt...
What are your favorite lesser-known gems/plugins for Rails?
This question about Rails plugins brought up only the usual suspects (Paperclip, RSpec, Shoulda, Restful Auth, etc). It'd be great to get a list going about the hidden, less popular ones that rock.
...
I've jus saw that mongrel's last updat was about one year ago...
http://mongrel.rubyforge.org/wiki/WikiStart?action=diff&version=35
has it been disontinued?
is there any other lightweight alternative for a windows development box?
...