I need to do multiple file uploads using nested form and jQuery. so I wrote an helper using link_to_function method:
def add_document_link(title, form)
link_to_function title do |page|
form.fields_for :documents, Document.new, :child_index => Time.now.to_i do |f|
page << "$('#documents').append('#{escape_javascript(r...
I'm writing and app to let the production people estimate costs for building some products,
they want to be able to give the product's base data (name of the product, client, etc) plus make the recipe for it (which materials are needed in order to build it) in the same page, and I was wondering how do I save tabular data in my rails co...
I am trying to sort the search results of a thinking_sphinx search. The columns I want to sort are in associated tables:
class Membership < ActiveRecord::Base
define_index do
indexes :title
indexes user.first_name, :as => :first_name
indexes user.last_name, :as => :last_name
has :organization_id, :active
set_property...
I'm using ruby on rails 2.3.8, and I've installed the acts_as_taggable_on plugin for tagging announcements and everything was fine until I discovered I had no easy and neat way of getting all the announcements tagged with a certain id(the only method I found was Tag.tagged_with(tag_name)).
So, I just wanted to relate the Tag model of th...
I have a "custom" validation method that I only want executed on create like:
validate :post_count, :on => :create
def post_count
# validate stuff
end
but it gets fired on update (in addition to on create).
Does the :on => :create symbol not work with "custom" validation methods?
THanks!
...
I'm trying to upgrade an old 1.2.6 Rails application to 2.3.8, and I'm running into a bit of a snag with migrations. Namely, if I have something like ModelName.create(:foo => "bar") in the migration, the migration doesn't complete. It doesn't hit an infinite loop or anything. It just refuses to complete that migration.
Here's some sampl...
The first layer is routing and the second layer the controller, so when in View, is there a way to dump out the path or filenames and line numbers of route and controller before reaching view?
I wanted to do this because www.example.com/stories/12345 is showing a page, but stories_controller.rb doesn't have a def index or def show
Upda...
I'm having trouble removing a gem from my system. When i ask gem where RedCloth is installed it says this:
pteng01:trunk mike$ gem list -d RedCloth
*** LOCAL GEMS ***
RedCloth (3.0.4)
Author: why the lucky stiff
Rubyforge: http://rubyforge.org/projects/redcloth
Homepage: http://www.whytheluckystiff....
I have Phusion Passenger running my Ruby on Rails application on my local machine, but I'd like to be able to kill the process entirely and run a different (non-Apache) service on the same port. Unfortunately, when I kill the passenger spawn server and the httpd processes, the spawn-server restarts:
15:30:37 /usr/bin $ ps ax | grep pas...
How can I know that I'm seeing all deprecation warnings?
Will they all print out at boot time? So firing up the console and viewing the output should be sufficient?
(if so, I don't have any. w00t!)
Thanks,
John
...
I am wondering what actually happens behind the scenes on the server when I create a Ruby on Rails application through the cPanel interface.
Is it just calling
$ruby script\generate
$ruby script\server
Or is there more to it?
...
I have a rails app with the whenever gem installed to setup cron jobs which invoke various rake tasks. For reasons unbeknownst to me, each rake task gets invoked twice at precisely the same time. So my db backup task backs up the db twice at 4:00am.
Inspecting crontab reveals correct syntax for all of the cron jobs, so I don't think th...
If I have a Ruby on Rails application running on my Apache shared server (with Mongrel), can I get it to launch/run another total separate Rack application?
Then could I possibly build a Rails app that manages other rails/rack apps? So it could tell what apps are running and start/stop them when I want. Or is each app trapped in it's ow...
Rails 2.3.6 started using the fast new json library, yajl-ruby, "if available".
In the "JSON gem Compatibility API" section of the yajl-ruby readme it outlines a method to just drop in yajl-ruby inclusion and have the rest of the app seamlessly pick it up.
So, ideally, I'd like
Rails to use it
My gems to use it
My application code to...
I'm a bit of a Ruby on Rails amateur, and I am trying to nest a div tag inside of an anchor tag in rails. I can make it work, but the resulting code I have written is terrible and is certainly NOT the rails way.
Here is an example of what I am trying to accomplish in HTML:
<a href="tell-a-friend">
<div id="tellafriend">
<strong>Str...
I have setup my own custom form for mechanical turk and am posting to their external interface.
<form enctype="multipart/form-data" action="https://workersandbox.mturk.com/mturk/externalSubmit" method="post" name="mturk_form" id="mturk_form">
<p>
<label for="turk_task_image_image">Upload an image</label><br>
...
Hi! I just released a Rails app in Dreamhost and I'm using Google Apps for my domain to handle Emai. I created the [email protected] account to serve as the sender authentication.
I installed smtp-tls plugin and my smtp conf is:
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:enable_starttls_auto =...
Here are my models.
Restaurant has many patrons
patrons have many transactions
In controller index all patrons like
@pts = Restaurant.find(1).patrons
and in view I simply list the patrons attributes, inluding number of transaction per patrons like
<% @pts.each do |p|
<%= p.transactions.count %>
How would I order the resultset (@pts...
I have a loop in my view that renders many partials: each partial is a simple toggle to perform a save/unsave operation on a record. Each partial toggles the boolean field using javascript then updates itself, and the controller finishes by saying:
$ controller
render :partial => "save_unsave_buttons", :locals => {:matching => @matching...
I'm creating a most popular activity section for user profiles. I have no difficulty pulling questions through the user_id but I'm having trouble pulling then ordering by the associated integer: question.votes.size . This is probably a simply question but how do I sort then limit the output to 3? How do I do this without lagging the data...