In Rails 3 I'm trying to call alias_method from my before_filter but I'm getting this error: NoMethodError in MyController#index
class ApplicationController < ActionController::Base
before_filter :my_test
protect_from_forgery
helper :all
def my_test
debugger
alias_method :new_method_name, :old_method_name
end
en...
Hello,
Has anyone been able to get the jquery-html5-upload plugin to work with Rails 3 + PaperClip + S3? Know of any tutorials?
http://code.google.com/p/jquery-html5-upload/
Thanks
...
I'm watching a Ryan Bates screencast on polymorphic relationships, and he uses this private method for finding all comments related to a nested model.
So I could find all the comments of a given Post with this :
def find_commentable
params.each do |name, value|
if name =~ /(.+)_id$/
return $1.classify.constantize.find(value...
For each species, I have many datasets. For each dataset, I have many phenotypes. The datasets have names which, within a species, are primary keys. The species, too, have string primary keys (e.g., Hs for Homo sapiens). So, I want to be able to specify a phenotype as follows:
/species/Hs/mcgary/1
where mcgary is the name (slug) of th...
because
gem 'gem_name' # Rails 3.0
or
config.gem 'gem_name' # Rails 2.x
will load the gem no matter what the controller is... will a
require 'gem_name'
in the controller source code actually make the Rails server run faster because not every controller will load that gem?
...
Hello. I'm using an AJAX uploader in Rails 3, along with paper_clip and have files uploading here:
def upload
@photo = Photo.create({ :photo => params[:file], :title => params[:filename] })
respond_to do |format|
format.json
end
end
I want to set the photo's title as the photo's filename, but don't know how t...
Hello,
in my def create controller I'd like to include something along the lines of:
:description = > 'Uploaded on May 27, 2010"
How can I make the May 27, 2010 dynamic in the controller?
Thanks!
...
Alright this one's tricky - don't shy off!
I've setup a multi-file uploader with Rails 3 + paperclip + Ajax Upload (http://valums.com/ajax-upload/)
My controller is as follows (which works):
def upload
@photoalbum = PhotoAlbum.create
@photo = @photoalbum.photos.create({ :photo => params[:file], :title => params[:filename],...
I have the following two models:
photoalbums
has_many:photos
photos
belongs_to:photoalbums
When I show a list of all the photoalbums, I want to also say how many photos exist in the album:
Controller:
def index
@photoalbums = PhotoAlbum.all
end
View:
<%# Get the number of photos per this album %>
<% @photos = Photo.find_b...
Is there a rake command in Rails 3 to clone my development database data? I noticed rake db:test:prepare and rake db:test:clone are mentioned throughout various blogs, but running them seems to do nothing. Furthermore, rake -T shows no db:test cases. I've resorted to loading a sql dump for now, but it would be great if I could just clone...
I have a simple polymorphic association
#comment.rb
belongs_to :commentable, :polymorphic => true
has_many :comments, :as => :commentable
#post.rb
has_many :comments, :as => :commentable
accepts_nested_attributes_for :comments, :allow_destroy => true
So in IRB I can do, Post.comments, or Commen...
I am working on the Rails 3 Test cases . While writing case i got Deprecation error like
DEPRECATION WARNING: Errors#on have been deprecated, use Errors#[] instead.
Also note that the behaviour of Errors#[] has changed. Errors#[] now always returns an Array. An empty Array is returned when there are no errors on the specified attribute...
I believe that rails 3 support for windows is not released yet. Can I use Netbeans IDE and start working with Rails 3 in windows operating system ?
...
I have the following classes with associations:
class Customer < ActiveRecord::Base
has_many :orders
has_many :tickets, :through => :orders
has_many :technicians, :through => :ticket
has_many :services, :through => :ticket
end
class Order < ActiveRecord::Base
belongs_to :customer
has_many :tickets
has_many :technicians,...
This seemed trivial at first, but I can't get it right for some time now. The relation is trivial.
class Project < ActiveRecord::Base
has_many :tasks
end
class Task < ActiveRecord::Base
belongs_to :project
end
Now I would simply want to get all the Projects which have 1 or more tasks associated. Now to do this without any extende...
I would like to return a string from a model, which can be used directly in the liquid-based template. The problem is, that I would like the string to be translated using gettext.
I cannot use _("string") right into model.to_liquid, because it doesn't work. As far as I understand, the model is loaded once, and it will always return the...
Hi all
I think I am thinking about routing all wrong. I have a very simple, two model set-up: Product and Photo. Product has_many :photos, and Photo belongs_to :product.
Product has a full scaffold while Photo has a photos_controller that I am working on.
In routes.rb we have:
resources :products (generated by the scaffold)
As phot...
Hey everybody!
What I'm trying to do:
I create some controllers, for example:
Home
About
Gallery
Contact
Now I want to create a navigation automatically. So is there a way to programmatically fetch the list of controllers/actions to build this navigation?
I don't want to fix the navigation everytime I add a controller.
...
Do the latest versions of these gems not work with each other any more? It appears that something may have gotten out of whack in my bundle.
undefined local variable or method `node' for #<Capybara::Driver::RackTest::Node:0x103e19390> (NameError)
./features/step_definitions/web_steps.rb:35
./features/step_definitions/web_steps.rb:14:in ...
Ok I need some expert advise here....
I have a Photo Album that has_many Photos... Common stuff right?
Where I need expert advise is I want the use to click the desired photo album... and then see one photo at a time...
Should that all be happening in the PhotoAlbum Controller? that's how I have it now but it's getting messy as I want...