I'm working on an association between two models:
class Person < ActiveRecord::Base
belongs_to :user
end
class User < ActiveRecord::Base
has_one :person
end
Many person records exist in the system that don't necessarily correspond to a user, but when creating a user you need to either create a new person record or associate to an...
I'm rendering polymorphic records in a view by looping over the polymorphic records and choosing the appropriate partial to use for the polymorphic relationship. However when a user is administering the site each polymorphic record may (or may not) have a second (alternate) partial that should be used in that situation.
So currently I'...
When I learned about proxy_options I started using it to test all my named scopes. But then I found myself simply copying the conditions hash straight from the model, so it wasn't really testing the correctness of the results:
po = {:conditions => "foo.created_at <= '#{Time.now.beginning_of_week}'"}
assert_equal po, Foo.created_this...
I am having trouble with some theory.
I have a model called Promos, and I also have a model called Categories.
I want the admin to be able to create set Categories from which the users will select in a dropdown to assign the Promo. So Promos will belong to a Category but the assignment ought to happen in the create.
What is the recom...
What I'm wanting to do is use 'button_to' & friends to start different scripts on a linux server. Not all scripts will need to be root, but some will, since they'll be running "apt-get dist-upgrade" and such.
The PassengerDefaultUser is set to www-data in apache2.conf
I have already tried running scripts from the controller that do li...
I'm using BlueCloth to create html from markdown from the content my users enter into a textarea like this:
def create
@post = Post.new(params[:post]) do |post|
body = BlueCloth.new(post.body)
post.body = body.to_html
end
...
end
This works great! I get the html stored in the database fine, But how do I show markdown in...
The answer for this question should be trivial. Is there any way to get in to the show action path to a given AR object within cucumber paths.(I am using factories to set up test AR objects).
I can refer in paths.rb new, edit and index paths but when it comes to show action it needs to specify the object and is there a way to refer that...
Hi,
I am using Ubuntu 9.04
I just installed ruby and rails in my system and the webrick server seems to have been installed without any errors.
I created a "demo" rails app and created a controller 'say'. Then i created a view template 'hello.rhtml'
I started the server and entered http://localhost:3000/say/hello in my browser.
But t...
it is showing me following error when i m opening http://localhost:3000/store
**We're sorry, but something went wrong.
We've been notified about this issue
and we'll take a look at it shortly.**
do anyone knows why it is showing me that error?
...
Hi,
I'm attempting to setup Ruby on Rails on IIS7. I've been reading lots of guides, but this seems to be the only up-to-date version I can find:
http://blogs.msdn.com/dgorti/archive/2009/06/17/ruby-on-rails-with-iis-7-reloaded.aspx
Although I have set the correct network permissions (and even as a test given the everyone group full ...
I'm new to Ruby on Rails, and I'm sure I'm just missing something simple and stupid, but I can't figure out how to get my 'account/signup' action working.
This is what I have in my routs file:
map.connect ':controller/:action'
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
map.root :controller => "...
Is there any (simple) way to get some control of the order in which a model's errors appear in the view? Ordering the rules does not seem to help whatsoever.
...
My models:
class Student
has_many :grades
has_many :courses, :through => :grades
end
class Grades
belongs_to :student
belongs_to :course
end
class Course
has_many :grades
has_many :students, :through => :grades
end
On my view page, for a student, I need to show all the courses and associated grades (if any)
Student: Joe...
I was looking at an authentication system which had this code:
# prevents a user from submitting a crafted form that bypasses activation
# anything else you want your user to change should be added here.
attr_accessible :login, :email, :password, :password_confirmation, :first_name, :last_name
I don't understand why attr_accessi...
I don't know if the term "mass assignment" is Rails-specific but I get the basic idea that mass assignment is when you assign values to a bunch of variables all in the same method.
Is that a correct definition and why is there a special name for this?
...
I'm running a Rails app through Phusion Passenger (mod_rails) which will run smoothly for a while, then suddenly slow to a crawl (one or two requests per hour) and become unresponsive. CPU usage is low throughout the whole ordeal, although I'm not sure about memory.
Does anyone know where I should start to diagnose/fix the problem?
Upd...
I am trying to convert from using MySQL to using PostgreSQL. I have this type of structure:
User(entity) -> Follow -> Business(entity) -> Story
The user needs to see all the news updates put out by the businesses they follow. The following query works great with MySQL because it simply shows all associated stories and groups by the sto...
Hi all,
I have a Rails app that I'm trying to deploy onto Glassfish using the Glassfish gem, but it's unable to load the jar files I've written. I've tried passing the jars' path to jruby explicitly with jruby -I, but no luck. Any tips? Thanks a bunch
...
What is the best plugin or gem for adding comments to the ActiveRecord models in rails?
Maybe there is one with ability to rate each comments with votes +1/-1 (like on youtube for example) and a cool view helper to display comments in a tree?
...
In my application I would like to provide a dashboard like screen when they login to get an overview of what is happening. I have about 4 models I would need to collect data from and sort them into order. My problem is knowing the action, so I can get specific fields per model.
Here are a few ideas of how to go about it, but I feel they...