I am trying to setup seed data for my Rails app and am counting on the id of each model being a certain value. How can I tell the table to, after MyModel.destroy_all to start counting from 0 again instead of where it left off?
...
I have an email form. But I'm making a test email form where a user can add a unique email, and have the email test send it to that particular email.
To make it easy, I decided to make the test email perform via ajax, and stick the whole thing inside of the other email form.
I can't figure out how to send the variables from my HAML to...
Hello
I am finding myself specifying :rows => 5 on all my text_area form helpers, So I looked up its definition and found the DEFAULT_TEXT_AREA_OPTIONS to be the hash dictating these options. However, the hash has this freeze method on it and I looked it up, it means it can't be changed. If you could recommend me some options to try to ...
Forgive me, guys; I'm still a complete RoR newbie.
I'm trying to use the will_paginate gem to add pagination to search results in my Rails app. Thus far it's been working great. However, I've hit a roadblock.
I have a "products" table with thousands of records that I want to be completely browsable. This is easy in the most basic scena...
I am using the following logic to update a list item based on a criteria.
def update_orders_list(order)
@orders.delete_if{|o| o.id == order.id}
@orders << order
end
Ideally, I would have preferred these approaches:
array.find_and_replace(obj) { |o| conditon }
OR
idx = array.find_index_of { |o| condition }
array[idx] = obj
Is...
Hello there,
I'm facing a problem right now, where in my company, we want to resize the thumbnail images we have on amazon s3 storage using attachment_fu, I've been investigating how to regenerate this thumbnails and had found some guidelines to do it, however all of them work with local storage.
I've found a way, that involves more o...
How do I write a find(:all) query in rails (v2.3.5) that has parameters both in the model I am running the 'find' on, and in another table? e.g. I am trying to search for 'posts' by 'author' and 'tag'. Author is an attribute of post, whereas tag is associated with it through another table. I can get the tags by including ':joins =...
I am migrating an existing application from Rails 2 to Rails 3. In the old environment file, SqlSessionStore was set up with:
ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.update(:database_manager => SqlSessionStore)
SqlSessionStore.session_class = MysqlSession
When trying to start my application in Rails 3, I'm told:
DEPRECA...
Hello everyone, I simply want a contact us form with name, email and message fields in my Rails app, I don't want to save(permanently) the message I just want to send the message as an email for a email account of mine. Can you help me?
Thanks!
...
I have a bunch of rspec tests that are taking entirely too long to run. I am trying to figure out where the bottleneck is and the logical place to start is using the standard libraries profile library. Execution is happening with JRuby 1.5.2 in this particular case. Here is the output after embedding the profile library in my spec:
% ...
The scenario is this:
I have some users on my site. A user has a role, the relevant ones here is admin and normal. I also have a model, let's call it SomeModel.
I have created a backend for the site, which uses an admin layout. All admins have full access to edit any content.
The problem arises with this relation: User -> owns -> Some...
I'm trying to stub out a method on my current_user (using a modified restful_authentication auth solution) with rspec. I'm completely unsure of how I can access this method in my controller specs. current_user by itself doesn't work. Do I need to get the controller itself first? How do I do this?
Using rails 2.3.5, rspec 1.3.0 and r...
does ruby on rails have an Admin section generation feature like django?
...
It is strange that if in the model:
def SomeClass
some_date: Time
end
then
SomeClass.where({:some_date.gte => '2010-09-01'})
would work well, but when it is
def SomeClass
some_date: DateTime
end
(change Time to DateTime) then the query won't work? (will get 0 items back).
In the MongoDB shell, they both show up as
> db....
How would I produce something like this in Rails ERB?
<li><a href="portfolio.html">Portfolio <span>Our work</span></a>
My problem is that ruby won't allow me to span inside of the link.
<%= link_to 'portfolio', portfolio_path %>
Anyway to get the Our Works Span inside of that link?
Thanks in Advance.
Solved
<% link_to portf...
I've been following the rails edge guide in building a simple recipe app, and I'm now trying to branch out and do a few more interesting things to try and learn more about rails.
Rather than only being able to edit an ingredient within an embedded form, I thought it might be neat to go to the recipe/:recipe_id/ingredient/:ingredient_id/...
Rails is a very great backend framework keeping everything clean and structured.
I guess that you all have thought about doing the same for the frontend.
Sproutcore
Cappuccino
Do you use one of thes MVC javascript frameworks for the frontend with Rails?
In case you do, do you feel satisfied with it?
How did you code before and how...
Could you tell me how to setup simplecov to test models with rspec and controller with cucumber only?
I don't like it that rspec and cucumber coverage are mixed together...
...
Is there a gem or plugin, that can generate a Comments with columns names above the class definition in Active Record model? I'm pretty sure that I've seen something like this, but can't find it anywhere:
Example:
# columns Defs
# name:string
# user_id:integer
# etc.
class Post < ActiveRecord::Base
end
I could as well write something...
Hey guys, in the following code:
def process(batch_size=1000)
claim_numbers.each_slice(batch_size) do |numbers_batch|
claims = Claim.find(:all, :conditions => ["claim_number in (?)", numbers_batch])
# do something with claims
end
end
In one of my Rails models I'm processing a lot of claim_numbers, I'm simu...