This is a strange one, I have created the following migration which fails to run.
class CreateCategories < ActiveRecord::Migration
def self.up
create_table :categories do |t|
t.column :name, :string
t.timestamps
end
news_category = Category.create(:name => 'Site News')
change_column :articles, :category_i...
I have been trying to determine a good way to test rails apps, covering all relevant aspects... since I have no experience writing tests at all I have been looking at railscasts.com which seems like a pretty good resource to learn basic stuff for rails. but for tests I have found several episodes, some using rails unit test classes, othe...
I have the following models but I cannot get the custom method reorder_action_items to work. I am obviously missing something basic.
class ActionList < ActiveRecord::Base
has_many :action_items
scope :today, lambda {
where("day = ?", Date.today)
}
def self.reorder_action_items(new_order)
new_order.each_with_index do |...
Hi everybody,
(sorry for my English ;)
I started to use CanCan from rbates, this is awesome gem, but I have some problems:
I have Scrap model and there is boolean field :published (so, it means published/not published (draft)).
I have this rule in my ability.rb:
can :create, [Scrap]
can [:update, :destroy], [Scrap] do |object|
obj...
We have Models like Supplier, Distributor, Vendor, Buyer in our schema. These entities have some common attributes ( like name, description, sales offices etc.) but mostly they have a divergent schema with different has_many :through associations ( a vendor has many stock_keeping_units , others do not) because of which they needed to be ...
This seems like an excellent script but lacks a key part to its installation I can't seem to figure out. Maybe someone out there can help a newb.
What I've done so far :
Installed the s3sync package.
Downloaded the s3 certificate
Downloaded the s3 ssl package
ran it with sh ssh.certs.shar
Edited the s3conf.yml file to have the correc...
I really like this syntax, though I forgot what it was called
@notifications.delete_if{|x| x == cookie[0].to_i
but I would like to do something similar for find
<% @managers = User.find{|x| x.isAdmin == true} %>
any ideas?
currently my solution tells me it can't find the object without an id, probably because I'm trying to treat a...
I have an RoR application with multiple CSS files.
YSlow complains about to many http request for the css files.
Now I have installed Jammit, to compress my css files into one file.
That works, but when some CSS file has an "import" directive, i get still an http request instead of simply get an single css file with all the included f...
In your experience, where is the best place to place scripts that run data loading jobs, but which rely on rails? In my project they are in the model folder, but that adds a lot of code to the model folder and won't rails load it all into memory when the server is run (unnecessarily)? The lib/ folder looks good, but those don't have rail...
This is a lot harder in code, than in real life. =)
But anyway,
My Users have managers, and vice versa...
How do I remove the relationship?
@selected_user = User.find(params[:id])
@selected_user.managers.delete_if{|x| x.standard_user_id == params[:id].to_i}
This is a self referential has and belongs to many relationship, so I have an...
When accessing my Rails app locally, I get the following error when loading any page:
/!\ FAILSAFE /!\ Tue Jul 06 15:08:17 -0500 2010
Status: 500 Internal Server Error
Expected /my_rails_app/app/helpers/admin/article_categories_helper.rb to define Admin::ArticleCategoriesHelper
If I follow the full trace, I'm brought to this line in ...
Without cookies enabled, a form post will throw ActionController::InvalidAuthenticityToken. For the most part, I just handle the exception with a message stating that cookies are required to login to my application.
However, one thing users of my application can do is create content to be shared with other people, who may or may not be ...
Is there any way to validate that a polymorphic association is only related to one item? for example, if I have a comments that are polymorphic and can be on photos, posts, etc. I want to ensure that if I am adding a comment to a posts' list of comments, that if the comment is already associated with the post, the add will fail. (validat...
I'm using cucumber, rails3, rspec2 and autotest. I'm trying to figure out why my features are infinitely looping. I suspect it some file being changed during the tests but I'm not sure which one. I've added some exceptions to my .autotest with no dice.
Are there any steps I can take to troubleshoot this problem?
It'd be cool if I could...
I want to create a very simple search partial. It has a text box, to query, and search db. Can I create a remote_function call without using AJAX or JS? Can I keep it entirely "Rails-ee"?
<%= text_field_tag "search_term",'', :size => 10 %>
<%= button "search", :onclick => remote_function( :url => {:action => :fill_in_lots }, :with => "s...
I have any array of structs. Each struct in the array has the following attributes:
user_id
num_hot_dogs_eaten
date_last_pigged_out
Here's what I want to do:
Find the structs with matching user_id's, and merge them into one struct record where num_hot_dogs_eaten is the sum of all matching records and date_last_pigged_out is the m...
We have a current database of users who can have any symbol in their username. We have started using authlogic for authentication. So, any current users updating any of their information fail validations because their login has unaccepted characters.
We want to prevent new users signing up from using symbols not accepted by authlogic, ...
I'm trying to add an entire folder to the JRuby 1.5 classpath for my Rails app. The JRuby Wiki suggests the following: "... add the config directory to the JRuby classpath in config/environment.rb:"
$CLASSPATH << "file:///#{File.expand_path(File.join(RAILS_ROOT, 'config'))}/"
That doesn't seem to work for me. It doesn't matter whether...
I use cookies to manage user sessions in my Rails app. I recently found that when a user changes the password, the cookie does not get invalidated as expected. As you realize, this could be a great threat to security. How should I handle this problem? I want to expire or invalidate a cookie once the user changes the password. How do I do...
I'd like to be sure if vestal_versions does support versioned associations (it seems like it doesn't) before switching out to another versioning gem that can support versioned associations e.g => has_versioning. I haven't looked at the code yet but I couldn't find anything related with versioned associations from the readme file or the i...