As it takes some time to prepare the content of the data to be downloaded, I want to show a message "Preparing file to download" when the user submits the request
Then when the file is ready, I use send_file to send the data
Once it's done, I need to clear the message
Thanks a lot
...
What is causing this error when I click on the edit button for a note? The delete button works fine. I created the note object with a scaffold.
index.html.erb
<% @notes.each do |note| %>
<%= note.detail %>
<%= button_to 'Delete', note, :confirm => 'Are you sure?', :method => :delete %>
<%= button_to 'Edit', edit_note_path(n...
I currently have two active record queries that I would like to combine together
joins("join relationships ON user_id = followed_id").
where("follower_id = #{user.id}")
and
where(:user_id => user.id)
Basically I want the results of the second one to appear with the first similar to a UNION statement in SQL. Can it b...
Hello all,
I installed the following gems in addition to rails 2.3.5:
i18n (0.4.1)
i18n_routing (0.3.7)
In environment.rb I added
require i18n_routing
Inserted the following lines in routes.rb:
map.localized(I18n.available_locales, :verbose => true) do
map.resources :users
map.resource :contact
end
but when I restart the se...
How do I add a default value to an existing field in a RoR migration?
...
For my next web application, I'm debating whether to use Rails 3.x or Sinatra.
I would like to use the server to provide user authentication, application-triggered emails, a fairly complex data model (behind ActiveRecord), and a JSON data interface with the web client. The client side will use static HTML, static CSS, Javascript/jQuer...
How would i translate these mysql queries to work with sqlite3?:
self.find(:first, :conditions => ['concat(first_name, \' \', middle_names, \' \', last_name) = ?', name])
self.find(:all, :conditions => ['(concat(first_name, \' \', last_name) LIKE ?) OR (concat(first_name, \' \', middle_names, \' \', last_name) LIKE ?)', "%#{name}%", "%...
I have setup a model relationship and all is working well when I use code similar to:
@parent.child.each do |item|
item.name
end
But how would I call just a specific child given there id
eg.
Child ID is 14
Would like a call like:
@parent.child[childid].name #>>>>>> CHILD'S NAME
...
This question is to piggy back off of a previous one I asked yesterday, which deals with moving the create/edit feature of a model onto its index page. One last issue I am having is that I when I go to delete a model, I have some javascript that is supposed to run that reloads the list of models to reflect the change in the database. Thi...
A newbie question:
I have a partial that I'm loading on a website on different pages.
That partial needs some data, so in the controller of the parent view I do the query:
@properties = Property.find(:all)
I pass the query results to the partial in the view using :locals
Now, I would like to render the same partial from another view....
Hi, I'm new to Rails. I have two models, Person and Day.
class Person < ActiveRecord::Base
has_many :days
end
class Day < ActiveRecord::Base
belongs_to :person
has_many :runs
end
When I try to access @person.days I get an SQL error:
$ script/consoleLoading development environment (Rails 2.3.8)
ree-1.8.7-2010.02 > @person = Per...
I'm looking to move the following code away from ActiveRecord to pure SQL for a performance increase. What would be the best way to write this query in pure SQL (MySQL DB)?
User.count(:conditions => ["email = ?",params[:email]]) > 0
Thanks
...
Ok so I am trying to import a csv which I need to insert into a db through rails or anyway that would be quickest so i decided to create a dummy rails application to do the importing. Here is some of the code below which I got some of it from a blog I was reading.
def upload
table = ImportTable.new :original_path => params[:upload][:c...
I'm having an issue writing a controller action that takes Post ids passed as a parameter and sorts them into a specific order before publishing them.
The Posts have a position attribute (I'm using acts_as_list for sorting), and are either published or unpublished (searchable with the named_scopes Post.published and Post.unpublished, ac...
In rails 2.3.8 I am having trouble with validations on a accepts_nested_attributes_for association if I loop through or even inspect the habtm association in validation the lessons are loaded and any updates are lost. For example, I have the following schema:
ActiveRecord::Schema.define(:version => 20100829151836) do
create_table "att...
I have posted another question similar to this, which I thought I resolved. But it is coming back with another symptom.
I am using REE/Passenger/Nginx and have the following in my nginx.conf
location ~* ^.+.(jpg|jpeg|gif|png|css|js|swf)?([0-9]+)?$ {
expires max;
passenger_enabled on;
}
Ever since I did this, it seems ...
Ok so i have the string "Product".
table_name = "Product"
I cant do
table_name.new
undefined method `new
So i was trying to find a work around like this
table_name = table_name.downcase.pluralize
name = ActiveRecord::Base.connection.tables.select { |t| t == table_name }.first
name.new
I am not sure this will work but even ...
I would like to format a number in a controller before inserting it into a string. But the function number_with_delimiter() does not work in a controller.
I need the string to send to a javascript plugin.
I could run the code in the view, but I guess that is not the best option.
@mycarousel_itemList = @mycarousel_itemList + "{url: '" +...
Hi there,
I'm searching for a good solution for integrating google maps into a ruby on rails 2.3 app. I know there's a project called ym4r but it seems old and not so maintained. Should I use directly the Google API itself?
Thanks!
...
i have
string = "$575.00 "
string.to_f
// => 0.0
string = "575.00 "
string.to_f
// => 575.0
the value coming in is in this format and i need to insert into a database field that is decimal any suggestions
"$575.00 "
...