that is, to tell the current Rails version it should use, and also to find out what version of Rails started this project.
...
Hi folks
I got the following snippet
Class Artist < ActiveRecord
attr_accessible :solo #boolean
def change_solo!
if self.solo == false
self.solo = true
else
self.solo = false
end
self.save
end
end
Is there a better way to write that? Thanks in advance
cheers tabaluga
...
I'm currently writing integration tests for a RoR REST API using cucumber.
I'd also like to stress-test the API and was wondering how I might be able to re-use my cucumber scenarios to do this.
I've used JMeter and httperf before for stress-tests, and of course with both tools had to write or record the tests that I wanted to include...
I am using PaperClip in one of my Rails applications. I notice that validation works as expected, but the label of the rendered file attachment does not get red. I checked the rendered HTML and the class required to make the label red does not go there.
Here is my code:
<div class="field">
<%= f.label :photo %>
<br/>
<%= f.file_f...
My problem is similar to the one in this question, but the opposite.
http://stackoverflow.com/questions/3876891/how-do-i-specify-layout-false-in-rails-respond-with
The controller is sort of a file converter. It responds to many formats. One format is supposed to render an html layout showing metadata. This format need the layout to be r...
I am trying to test the render method in a controller with RSpec (2.x).
Here the code in my controller:
respond_to do |format|
format.html # index.html.erb
format.json { render :json => @entities, :include => :properties, :overview => options[:overview] }
end
And here the test I try in my spec file:
controller.should_receive(:r...
Hi All,
I can't seem to render a template outside of a controller in my Rails 3 application. The googling I've done has been helpful, and I eventually found some useful info at http://www.swombat.com/rails-rendering-templates-outside-of-a-contro. However, this seems to be broken in Rails 3. Does anyone have any ideas how I can fix this m...
I've been trying to create a user date-of-birth selection field during sign up.
The code looks like this:
<div id="content">
<h3>Register</h3>
<%= form_for(@user) do |f| %>
<div style="width: 374px; margin: 0 auto;">
<%= f.label :name %>
<%= f.text_field :name %>
<div style="clear: both;"></div>
<%= f.lab...
Hello,
I'm working on a Rails app.
I want to test with rspec my method "start!" of my model Backup.
So here the specs (all are methods, too):
Backup should copy files to folder /backups
Backup should check md5 sum
Backup should delete original files
For my tests, I create fake files, based on fixtures :
MyFile.all.each{|r| system(...
If I have Firebug console open, and return the following in a rails controller in response to an ajax call:
format.json { render :json => Appointment.find_by_id(1) }
I get an 'invalid label' error. But it works fine it Firebug is closed.
Any ideas???
...
With RoR, you have your model, controller and view.
The model has both class properties etc., and db access code mingled in.
In your controllers, you use your models to fetch certain data to push to your views.
In the Java world, you would have a DAO per entity, and then a 'Service' layer where you could decide to pull the object from...
Hi,
We're having huge problems with the delayed_job plugin - http://github.com/collectiveidea/delayed_job/
When we start tasks with "ruby script/delayed_job start", the process never lets go of RAM it acquires.
So it starts with 10%, 25%, gets to 80% and never lets go of the ram, even if it has no jobs to process.
Any ideas how we ca...
Im new to Rails, and decided to start of with Rails3. After a lot of searching ive managed to get a little bit of Authlogic working. I'm able to register a user, login & logout.
Now, I would like to add more features, get more of authlogic working. I'm using Railscast EP 160 as my reference.
Portions of the code found on the tutorial t...
Hello. I'm diving into ASP.NET MVC and I'm coming from a Ruby on Rails background. I'm trying to understand how ASP MVC handles AJAX functionality and, after reading some of the tutorials on the ASP website, it appears they implement AJAX functionality very differently. One of the ways that RoR handles AJAX functionality is by returni...
The anti-pattern that I want to kill is:
- if !current_user
# do something
- if !member
# do something else
- if admin
# blah blah blah
- else
# Bored now.
I suspect the answer has something to do with view helpers and partials, but I'm wondering what some of the best practices and design patterns are. Thanks!
...
I am wondering if the counter_cache would work in single table inheritance.
For these models:
class User
has_many :questions
end
class Question
belongs_to :user, :counter_cache => true
end
class SimpleQuestion < Question
end
class ComplexQuestion < Question
end
So will the following counters work?
create_table(:users) do |t|
...
Rails 3.0.1/Ruby 1.9.2 with Postgresql 8.4 work great on my home machine, however I'm getting this error on a Ubuntu server.
I'm sure that the password I upplied in the database.yml file is correct, because when I log in as "postgres", it lets me in:
sudo -u postgres psql template1
Password:
psql (8.4.5)
I have edited the "pg...
We have a Ruby on Rails 2.3.8 project, where data are almost exclusively read only.
We would like to write acceptance tests which use staging database (copy of the production database)
So we do not want to use transactions or truncation of the database tables before or after features and scenarios.
Is it possible?
...
I am trying to convert my Rails 2 app to Rails 3, but I can't delete any resources using my old Rails 2 code. To be precise I am trying to delete a resource, using this link:
<%= link_to image_tag("misc/delete.png"), @book, :confirm => 'Are you sure?', :method => :delete %>
And yet it doesn't work at all! It just behaves as if the :co...
I need to write a Rails application (JRuby) that does asynchronous communication with another service in the background. There needs to be one connection per browser session. (It does not really need to be a open TCP connection but I need to free resources after the session ends.) The communication with the background service is not stri...