Here's my question. I have a user model with one attached avatar. This model has many personal photos (with accepts_nested_attributes_for).
I want to be able to initialize a personal photo automatically after saving a user object with whatever the user avatar turns out to be. So say Bob uploads his avatar, bob will automatically have on...
Hi,
In a controller I have 2 actions
def action1
session[:test]="test"
render :text => session[:test] # output test
end
def action2
render :text => session[:test] # output nil
end
I perform first action1 so the session is set
Then I perform action2 but session[:test] is nil
So what am I doing wrong?
...
I'm transitioning to heroku, and need to have AWS-s3 connections to deal with a variety of graphics.
I've installed the aws-s3 gem, but one of its dependencies is not being found: xml-simple. My belief is that this is a standard part of RoR, and it is in the gem list. When I deploy to heroku, all is fine, but on my development server, i...
I'm currently working on a project where users can upload datasets in CSV format.
Is there a good way with Ruby other than checking file extension to determine if they're really uploading a CSV and not some executable or some other file type?
...
I was using some image cropping example that I found online and now I got confused. There is actually no "crop" method in my controller. Instead (following the guide) I put a
render :action => 'cropping', :layout=> "admin"
In my create method. That renders a page the view called cropping.html.erb . It works fine but I have no idea h...
Hi,
I'm trying to do the following:
Run a Worker and a method within it every 15 minutes
Have a log of the job last runtime, in the database table
bdrd_job_queue.
What I've done:
I have a schedule every 15 minutes in my backgroundRB.yml file
The method call has a persistent_job.finish! call, but it's not working,
because the persi...
I'm trying to create a ruby gem for rails out of a plugin I've created. The problem is that my plugin 'shortcuts' uses a few javascript files which need to be in the public/javascripts directory to work.
What's the best way to make these javascript files which are in the gem I've created accessible by which ever project requires my gem...
I have a method song_link that calls link_to internally. I want the caller to be able to pass an options hash to song_link, which will then use the options relevant to it, and pass the rest to link_to. Here's my code:
def song_link(song, separator = nil, options = {})
if separator.class == Hash
options = separator
sepa...
Hello,
I have the following HTML doc :
<ul>
<li><span>Some text</span></li>
<li><span>Some other text</span></li>
<li><span>Some more text</span></li>
</ul>
How can I use Hpricot to loop on the list items and insert some new HTML at the beginning of each, so that I get the following :
<ul>
<li><span>1</span><span>Some text</...
I get this error when I try to use time_ago_in_words:
Comparison of String with ActiveSupport::Duration failed
I'm trying to check whether an object was created more than 8 minutes ago:
<% if time_ago_in_words(obj.created_at) > 8.minutes %>
<p>Yes</p>
<% end %>
Would appreciate it if anyone knows the correct way to perform...
When i use User.count(:all, :group => "name"), i got multi rows, but it's not i want, what i want is the count of the rows, how can I do it?
...
I have a Page model that goes 1 generation deep. How can I do my routes so that
/about
/about/leadership
/about/vision-and-mission
/contact
/join
/join/benefits
work?
The slugs come from the friendly_id plugin, and are all unique.
...
I have a controller which has a method called history
class UsersController < ApplicationController
def history
User.return_history(params[:id])
end
end
I have the following in my routes.rb file
map.resources :users, :shallow => true do |user|
user.resources :friends, :shallow => false
user.resources :posts, :colle...
I'm aware of dynamic routes but I'm a little stumped with this, with the search gem I'm using it performs a get and my route is thus myapp.local/recipes?search=chicken
How can I make this a route? so that it would stay in the recipes controller but appear to the user like a nested route, like this myapp.local/search/chicken
...
I am trying to develop a forum with altered_beast for 2.3.3. I am presently working with Rails 2.3.4. I would like to know how altered beast works. It seems be an entire project on its own, so how should i go about setting it up.
Another error that I encounter when i use it as an application (which seems wrong to me) is a mysql error wh...
this is the problem:
inside a lib i need to print MONTHNAMES to string
if i try
Date::MONTHNAMES.inspect
result is
=> "[nil, \"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"]"
that's good but i don't need the first element, so
month_n...
Given a model with *default_scope* to filter all outdated entries:
# == Schema Information
#
# id :integer(4) not null, primary key
# user_id :integer(4) not null, primary key
# end_date :datetime
class Ticket < ActiveRecord::Base
belongs_to :user
default_scope :conditions => "tickets.end_date >...
I just saw that whitehouse.gov is using drupal as a CMS and portal technology.
One of the advantages of drupal seems that it is easy to add plugins and that programming is minimum, i.e. that re-inventing the wheel is at minimum. That is actually exactly the DRY philosophy of Ruby-on-Rails. So:
What are the drawbacks of drupal?
What wou...
Hello there. We have a rails app running on passenger and we background process some tasks using a combination of RabbitMQ and Workling. The workling's worker process is started using the script/workling_client command. There is always only one worker process started, and the script/workling_client has a :multiple => false options, thus ...
I have a Rails application which uses another Rails application's API trough a WSDL file. I'd like to somehow cache or define as a constant the "handle" to the API which I create like this:
serv = SOAP::WSDLDriverFactory.new(APP_CONFIG['api_url']).create_rpc_driver
Reloading this for all methods which use the API is both slow and not ...