I have a very complex controller with a very complex set of views and partial views that I'm trying to clean up (not written by me originally).
In the controller, it defines member variables, like:
@blah = "blah"
which I'm not sure if they are used in a view, or a partial view, or a partial view called by a partial view. Is there any...
I'm trying to create a record within a join table from the action of a button. To explain, I would have an events model and would like to track selected events from each user.
I used the HABTM relationship since I dont really need any extra fields.
User.rb => has_to_and_belongs_to_many :events
Event.rb => has_to_and_belongs_to_many :u...
Has anybody here successfully installed the system_timer gem on Windows?
I have devkit on my machine and I am able to install other native gems.
I get the following error when I install the gem.
In file included from system_timer_native.c:2:
c:/Ruby19/include/ruby-1.9.1/ruby/backward/rubysig.h:14:2: warning:
#warning rubysig.h is o...
Is there a way to write this in the command line that will auto-generate the migration script below?
Example:
ruby script/generate migration renamePostsTableToActicles
Generates:
class RenamePostsTableToActicles < ActiveRecord:Migration
def self.up
rename_table :posts, :articles
end
def self.down
rename_table :articles,...
Is it possible to have multiple has_many :through relationships that pass through each other in Rails? I received the suggestion to do so as a solution for another question I posted, but have been unable to get it to work.
Friends are a cyclic association through a join table. The goal is to create a has_many :through for friends_comm...
Hi,
I'm using shoulda with Ruby on Rails, and I have the following test cases:
class BirdTest < Test::Unit::TestCase
context "An eagle" do
setup do
@eagle = Eagle.new
end
should "be able to fly" do
assert_true @eagle.can_fly?
end
end
context "A Crane" do
setup do
@cra...
I have two Rails apps that I want to serve with Passenger from the same domain.
I would like requests to come in to one app, and if that app is not able to handle the request, for the request to be passed to the the second app.
I know that I can use Passenger's RailsBaseURI option to deploy multiple apps to different sub URIs, but this...
Hi ppl,
I am having this bizarre error and I don't know what to do.
This code runs fine on my development and staging machine but crashes on production.
All I have to do is load the page or call script/server to trigger the following error:
Error message:
interning empty string
Exception class:
ArgumentError
Full Stack trace: Code...
Hi there, I'm working on a newly configured computer, and can't seem to get rails to play nicely with my gems. Below are some of the errors I'm running into.
If I run 'script/console' in a rails project, I get the following error:
Missing the Rails gem. Please gem install -v= rails, update your RAILS_GEM_VERSION
setting in conf...
Specifically, I'm trying to figure out if it's possible to generate SQL that does what I want to feed into Ruby-on-Rails' find_by_sql method.
Imagine there are Users, who are joined cyclically to other Users by a join table Friendships. Each User has the ability to create Comments.
I'd like a SQL query to return the latest 100 comment...
Is it possible to impose conditions on a SQL query to the greater of two conditions?
For example, imagine a site that has Posts. Is there a way to request posts such that the result will be guaranteed to contain both of at least all posts made in the past 24 hours, and at least 10 posts, but not unnecessarily exceeding either limit?
I...
I've got a simple form on a User page that allows a User, once they have logged in, to change some attributes on their own user object. The view:
<% form_for @user, :url => {:controller => "teachers", :action => "update"} do |f| %>
<%= f.error_messages %>
<%= f.text_field :display_name %>
<%= f.submit "Update" %>
<% end %>
...
I have a simple Ruby on Rails form which includes an authenticity_token. Unfortunatly, I missed that when you page cache this page then the Authenticity Token becomes invalid. I'm glad I figured it out however.
How do you solve caching in such a case?
...
Apparently, include and select can't be used simultaneously on a Rails find query, and this has been repeatedly marked as wontfix:
http://dev.rubyonrails.org/ticket/7147
http://dev.rubyonrails.org/ticket/5371
This strikes me as very inconvenient, because the times I'd want to use include are exactly the same times I'd want to use select...
Where would I go about placing partial files shared by more than one model?
I have a page called crop.html.erb that is used for one model - Photo.
Now I would like to use it for another model called User as well.
I could copy and paste the code but that's not very DRY, so I figured I would move it into a partial.
Since it's shared betw...
Hello,
Just thinking about the best way to build an Order form that would (from user-perspective):
Allow adding multiple items.
Each item has Name, Job Type drop-down and File upload.
User can add or remove items.
User must provide at least one item.
All the items should be validated (eg: Name, JobType and File are required).
When he ...
I am using the following method to get the time of the video with ffmpeg do not know what reason I can not put the output of the command
command = ~ / Duration: ([\ d] [\ d ]):([ \ d] [\ d ]):([ \ d] [\ d ]).([ \ d] +) / variable for time and then insert in the
can someone give a help?
def get_time_video
command = system " ffmpeg -i vi...
I'm working on an application that models friendships between users.
class User
has_many :friendships
has_many :friends,
:through => :friendships,
:conditions => "status = #{Friendship::FULL}"
end
class Friendship
belongs_to :user
belongs_to :friend, :class_name => "User", :foreign_key => "friend_id"
end
...
Im not sure if I'm doing this right. I have an action that I would like to either copy, create, and save a new object if a user is logged in, or redirect if they are not logged in. Im not using a form here because I am using a stylized button with an image that looks like this:
<a href="/lists/add/<%= @list.id %>" class="button">
<s...
relate question: http://stackoverflow.com/questions/2379270/vote-fu-and-ajax-requests
There seems to be something wrong with my Ajax request.
What I 'm trying to do is on event click vote submit a vote then update page with out refreshing the page.
votes_controller.rb:
def create
@album = Album.find(params[:album_id])
respond...