I have a Rails 3 app that defines some classes like normal. I am trying to figure out how to reopen one of those classes within a plugin (generated by "rails generate plugin ..."), and have both of the files (the file in the app itself and the file in the plugin) automatically reload on every request in development mode.
A simple exampl...
Hi,
I'm using the original Juggernaut (not Juggernaut 2) with Rails 3. In the lib/juggernaut.rb, it breaks due to not being able to find @template. According to this other post, @template is not provided in controllers in Rails 3.
How can I fix the following code, so that it can run smoothly with Rails 3? (Here's a link to the origin...
Both methods put the gem into the project's folder to be a self-contained project. Is there advantage / disadvantage of these methods or one better than the other method?
(the project is a Rails 2.2 project, so can't use Bundler)
...
Hi,
For a Ruby on Rails app, I'm having this Movie object which has several attributes. Pretty much every page needs to compare some movies to a full list of these movies sorted by ratings, so I used to cache this big sorted list. It was useful, because I could directly use this list of Movies and all their attributes without any other ...
I have a Rails app set up so that when a user uploads an image, it is sent directly to Amazon's S3. I have to specify a redirect address in the form code. After the image is finished uploading, Amazon redirects the user to www.redirect_address.com/?bucket=[BUCKET]&key=[KEY]&etag=[ETAG]
I need the bucket and key info to process the image...
Hello all,
I have a need in my app to allow users to bookmark a post. They should only be able to create one bookmark per post. I've set up my polymorphic association like so:
class Post < ActiveRecord::Base
has_many :bookmarks, :as => :bookmarkable
end
class Bookmark < ActiveRecord::Base
belongs_to :bookmarkable, :polymorphic =...
I have a method in my application helper that is meant to deactivate a task in my database.
Application helper:
def link_to_destroy_task(task_id)
Task.find(task_id).deactivate
end
Model:
def self.deactivate()
update_attribute(:active, false)
end
View:
<ol id="tasks">
<% @Tasks.each do |task| %>
<%content_tag_for...
I have a view of a Model, and there is an attribute 'direct' which can either be 'true' or 'false'.
Am wondering if there's a standard way or even a plugin/gem or just good suggestions on how that can be toggled on or off in the view.
I found myself writing alot of logic in the view so stopped and sought some guidance.
A simple versio...
Hi all,
I'm implementing Authlogic and attempting something i haven't done before. I basically have two tables:
account_holder: this has all the standard columns you'd expect...email, crypted_password, etc.
session: this has account_holder_id, persistence_token, last_request_at, last_login_at, etc.
Basically i was hoping to store a...
I need to define some common piece of code that can be invoked from different controllers(not view). Is there a way to do that in Rails v3?
I have defined the code in ApplicationHelper and tried to invoke it using
@template.<helper_method>
and
ActionController::Base.helpers.<helper_method>
But it does not work?
...
I am trying to create a rspec test for a model for States. This state model has an association to a Country model. My factories look like
Factory.define :country do |country|
country.name "Test Country"
end
Factory.define :state do |state|
state.name "Test State"
state.association :country
end
I have made a functional state...
If installing a gem using
gem install ______
actually install 6 gems, because of the dependencies, then if the gem is installed as plugin by
script/plugin install git://github.com/author/____.git
or
script/plugin install _____
then we to manually install the gem it depends on?
Does it matter if it is the later form, where it d...
I'm new to testing and rails but i'm trying to get my TDD process down properly.
I was wondering if you use any sort of paradigm for testing has_many :through relationships? (or just has_many in general i suppose).
For example, i find that in my model specs i'm definitely writing simple tests to check both ends of a relationship for r...
I need to collect and store mailing addresses in a Rails (2.3) app. Is there a Rails way to do mailing addresses? For example, I would do f.date_select to generate a series of dropdowns to handle dates, which are then stored in the database, which I defined in schema and migrations as t.datetime "foo". I would consider that the canonica...
Here is how I created an array:
@companies_with_email = Company.contact_emails_date_sent_gt(@monday).
contact_emails_date_sent_lt(@friday).
find(:all, :select => "distinct companies.* ") || []
@companies_with_call = Company.contact_calls_date_sent_gt(@monday).
...
So currently I have an issue where I am populating a database from xml files through my client's API. Each record has an expiration date in it, with the following format:
<offer_ends_at>2010-10-20T07:59:59-04:00</offer_ends_at>
Now, I need to run a query where I only get records that have an expiration in the future. My current code i...
I'm trying to make a stripped-down user sessions system, and tried to model it to be similar to authlogic.
class UserSession
attr_accessor :username
def initialize(params={})
@username = params[:username]
end
def new_record?
true
end
def self.find
return nil if session[:username].nil?
UserSession.new sessi...
It seems that both methods can freeze a gem into the vendor directory, but rake gems:unpack requires the gem to be listed
in config/environment.rb as config.gem '<name of the gem>' before the rake is done.
On the other hand, rake gems:freeze requires installing the gem gemsonrails first, and uses the syntax rake gems:freeze GEM=haml and...
If I run
gem server
and go to localhost:8808, one of the entry is haml and it says it depends on maruku and yard
haml 3.0.22 [rdoc] [www] - depends on maruku, yard.
An elegant, structured XHTML/XML templating engine. Comes with Sass, a similar CSS templating engine.
Executables are css2sass, haml, html2haml, sass, sass-convert.
b...
I'm trying to allow users to vote a record up/down with Ajax. I'm using the vote_fu plugin for the voting functionality, and everything works fine without Ajax. I'm now trying to figure out the best way to implement the asynchronous functionality with unobtrusive javascript.
What I'm doing now is having two buttons, "Up" and "Down", suc...