Hi,
I have some models - NewsArticle, Comment, User (as :author) and Profile.
class NewsArticle < ActiveRecord::Base
belongs_to :author, :class_name => "User", :foreign_key => "user_id"
has_many :comments, :as => :commentable, :dependent => :destroy, :order => 'created_at', :include => 'translations'
end
class Comment < ActiveRecor...
I read that as you are using the default Rails stack you are happy, but if you try to swap something then the real headache begins.
How hard is it to use jQuery instead of Prototype and Haml instead of ERB?
(I'm not Rails developer, I just trying to collect some info about it).
...
Hey,
Erb is the default template type in Rails and I read about Haml.
What other types exist and can be used in Rails?
Thanks.
...
Is it possible to run a SQL job from Ruby on Rails application?
...
Hi,
I have a form that i want submitting with AJAX, using rails 3 and jquery. The problem that I am facing is that rails is responding to the AJAX request as HTML too. After a little search I found that this has something to do with the correct Accept headers not being passed. How do i fix this?
This is the controller code
respond_t...
If a few of my models have a privacy column, is there a way I can write one method shared by all the models, lets call it is_public?
so, I'd like to be able to do object_var.is_public?
...
I am trying to attribute the time param with .to_date to generate the proper comparison
Organization.find(1140).events.all(:conditions => ["time < ?", Time.now.beginning_of_day]).blank?
How would I do that? I tried this :
Organization.find(1140).events.all(:conditions => [time.to_date < ?, Time.now.beginning_of_day]).blank?
And tha...
Hi guys
I have a select input on my page. this select input displays/hides fields in the form. This all works fine. But the problem is that if i submit the form and lack some necessary fields, it doesnt set the select to the right value afterwards. I just cant get the embedded ruby to work! it keeps escaping the whole thing... here my c...
Disclaimer, I know very little about Rails. I'll try to be succinct.
ModelA belongs_to ModelB
ModelB has_many ModelA
The JSON Show action of the ModelA controller should show all ObjectA's that are belonging to the ObjectB of which the ObjectA in question is a member of.
So if I have an ObjectB that contains ObjectA's of ID 1, 2, and ...
I'm a little stumped as to get the order of records I want with a find operation.
Let's say you had three models:
1. Websites
2. Links
3. Votes
A website has many links and a link has many votes. Each vote has a certain amount of points that a user can attribute to that vote. I'm trying to get a website index page where websites are li...
I'm using the acts_as_commentable_with_threading plugin. It comes with a comment model in comment.rb:
class Comment < ActiveRecord::Base
....
# NOTE: Comments belong to a user
belongs_to :user
....
However, when I have a Comment object called comment, I can't call comment.user as I would have expected to be able to. In par...
When I run rake ts:conf, I get "Can't connect to local MySQL server through socket '/var/run/mysqld/mysql.sock' (2)"
This socket file does exist.
...
Hi,
I have a Place model that has both 'city_name' and 'name' as attributes. I would like to define a custom method that finds the place whose name matches the city_name for another place eg.
Place.name = "foo"
Place.city_name = "baz"
then Place.find_city gives the record where Place.name = "baz". At the moment I've got something alon...
In Redmine, I need an alternate to the Target Version field in a ticket. Basically, I would like to pre-define a large number of version numbers and then assign more than 1 version number to a ticket. For example a ticket can be assigned Software 1.2.0 and Hardware 1.1.0. The List Format for a Custom Field will not work because you can o...
I'm using paperclip to attach photos to one of my models:
class User < ActiveRecord::Base
has_many :photos
accepts_nested_attributes_for :photos
end
class Photo < ActiveRecord::Base
belongs_to :user
has_attached_file :data
end
How can I use reject_if to ignore data fields to which files are not uploaded by users?
...
Is there a way to "reload" or "refresh" a rubygem in memory? As i'm playing in irb, occasionally I like to modify my gem files, and if i require the same gem, it does not update into memory and gives the output "false". Currently I have to exit IRB, get back into IRB and then require the gem again, there has to be a better way...what is ...
I have a kind of legacy db structure with rails.
It has a structure like:
apples
id:
number:
oranges
apple_id: (links to apples.number)
pears
apple_id: (links to apples.id)
Models like:
Apple has_many :oranges, :foreign_key => ?, :primary_key => ?
has_many :pears
Orange belongs_to :apple, :foreign_key =>...
Hi
My Controller waits for a response from a lib folder ruby file which it is calling.
lib.rb runs for about 4 minutes and returns a string as result.
The controller waits for the string response and then application breaks after a minute showing Internal Server Error
what should i Do?
Regards
...
How do I call a class from a string containing that class name inside of it? (I guess I could do case/when but that seems ugly.)
The reason I ask is because I'm using the acts_as_commentable plugin, among others, and these store the commentable_type as a column. I want to be able to call whatever particular commentable class to do a f...
This is a really simple question and despite multiple Google searches I cannot find the relevant one-line command. What do we enter in view.html.erb to show all the contents of the current session?
...