I have been having a problem when I try to compare two Rails models. They should evaluate as the same, but the way ActiveRecord implements == is causing it to fail. What's even stranger is the unit tests are passing.
Suppose a User has many Posts, and Posts has many Comments. User also has_many comments.
(and this is comparing two obje...
I have a rake task that processes a set of records and saves it in
another collection:
batch = []
Record.where(:type => 'a').each do |r|
batch << make_score(r)
if batch.size %100 == 0
Score.collection.insert(batch)
batch = []
end
end
I'm processing about 100K records at a time. Unfortunately at 20
minutes, ...
I am trying to show a rails view file in a textarea. the view file contains a bunch of HTML, which I want to escape so that it does not interfere with on page html. here is an example:
In this view we are going to display the contents of a partial
<textarea>
<%= html_escape render('partial') %>
</textarea>
and in partial.html.erb I ...
I just updated from jQuery 1.3.2 to 1.4.3, and I'm seeing some new behavior when making AJAX DELETE requests. For some reason, the data being passed in my data parameter is not being sent to the server. For example:
$.ajax({
url: '/example',
data: {id: 12},
type: 'DELETE'
});
Ends up sending a DELETE request to /example ...
Apparently, I am using params[:category] (from routing...) to categorize some articles within same table, and I just want to set the category column of an article to be params[:category]. I tried just saying
class Article < ActiveRecord::Base
has_many :comments
belongs_to :article_category # this is the model that has info about ca...
I am using Paperclip to, among other things, allow a registered user to upload an avatar for use on thier profile. I want to store a big and small version of the image which will be rmagicked to standard sizes. Now, what i want to do, is store these two standard sizes (:normal and :tiny, for example.) but I do not want to store the :orig...
I'm trying to connect from Ruby 1.8.7 on RHEL 5 to MS SQL Server. I'm using FreeTDS and the tiny_tds RubyGem.
I got it working fine on OS X.
On Linux I installed FreeTDS and confirmed that it can connect to SQL Server from the command line no problem. And gem install tiny_tds went fine.
However, when I deploy to Linux and try to open ...
Given:
<%=form_for [:project, @note], :remote => true do |f| %>
I'd like to create a jquery bind that automatically saves every few seconds. I'm not worried about the timing part yet, just how to use jquery to submit the form automatically (ie, not submit button click by the user.)
I tried this, but it isn't working. Suggestions?
$(...
I'm involved in preparing a pre-existing rails application for translation - going through the files under app/views/, finding the text, making a key in config/locales/de.yml (in this case), copying the text into de.yml, and putting t("key") in the view file. Repeat hundreds, maybe thousands of times. This is very tedious.
I don't think...
I use RSpec to test my lovely little web app. For integration tests I use Steak. When using Rails generators (yep, I know that this is not the Zen way of doing TDD) there are also some files in spec/requests generated. As stated on link text it is something similiar to integration test (but I couldn't find much more info).
Are those req...
For integration tests of my Rails web app I use Steak (something like Cucumber). The specs of Steak are in a folder named spec/acceptance. Are Steak/Cucumber now for integration or acceptance testing? I always thought that this is something different.
...
Is it possible to stub an entire chain using Mocha? For example, I want to stub:
User.first.posts.find(params[:id])
such that it returns a predefined post instance instead of accessing the database. Ideally, I'd want to do something like:
@post = Post.new
User.any_instance.stubs(:posts,:find).returns(@post)
As you can see, I'm stub...
This is what I've used with remote_form_tag:
<% form_remote_tag(:url => {:controller => '/companies', :action => 'update'},
:update => 'tags') do %>
<%= text_field :company, :tag_list %>
<%= submit_tag 'Save' %>
<% end %>
This is in a Company.view, where Company is a model that is acts_as_taggable_on enabled.
...
I updated to Rails 2.3.10, Rack 1.2.1 and now none of my flash messages are showing up. I found that during a redirect the notice is passed in like this
redirect_to(@user, :notice => "Sorry there was an error")
And in my view the flash hash is empty
<%= debug flash %>
!map:ActionController::Flash::FlashHash {}
But you can see t...
Hi. Here's what I'm trying to do.
when the user clicks new note.. I want the user to be taken to a page when they can start typing a note, and save it to the server all with AJAX..
Problem is, every time the page saves, it's making a new note.
This leads me to believe that when Rails gets the DEF NEW controller, some how I need rails ...
I added a table that I thought I was going to need, but now no longer plan on using it. How should I remove that table?
I've already ran migrations, so the table is in my database. I figure rails generate migration should be able to handle this, but I haven't figured out how yet.
I've tried
rails generate migration drop_tablename, but ...
I have this but I'm pretty sure that is not the best way to build it up.
var dogs = {
'names' : ["a", "b", "c"],
'images': [
<% @dogs.images.each do |image| %>
{
'thumb' : '<%= image.thumb %>',
'medium' : '<%= image.medium %>',
} <%= "," unless(@dogs.images.last.id == image.id) %>
<% end %>
]
}
Thanks for your he...
Hello,
I'm using STI in Rails, and I've got a Vehicle object, that has many different types of subclasses, like Car, Truck, etc. It's for a simple app, so STI works fine in this case, but I'm having trouble creating a single form where any type of Vehicle record can be created.
Using the following routing:
resources :vehicles
resource...
Hi! Here is my Rails 3 nested routes structure for PROJECT
resources :projects do
resources :notes, :photos
collection do
get 'yourproject', 'newjs'
end
end
This works great for things like
/projects
/projects/1
/projects/1/notes/
/projects/1/notes/3
what isn't working is:
/projects/1/notes/newjs
Anyone Rails 3...
As the quantity of our pages increases, the number of images in the rails project has increased greatly. Does anyone have a good strategy for keeping track of these images?
We have experimented with a couple ideas but nothing seems to solve everything. Here are the high level requirements we have come up with:
Images should be avail...