As a direct result of my own stupidity I have managed to somehow get my database in a broken state and can't figure out how to fix it.
The problem started with a typo in one of my db migrations. I was adding a column and mis-spelled the name of the table that I wanted to add the column to. I ran 'rake db:migrate' and it failed. So I ...
Hello, I'm working to install the acts_as_commentable plugin on my
Rails 3 app.
After adding "acts_as_commentable" to my book model, I then added a
comment form on my book show view:
<% form_for(@comment) do|f| %>
<%= f.hidden_field :book_id %>
<%= f.label :comment %><br />
<%= f.text_area :comment %>
<%= f.submit "Post...
Using Rails 3.0, I have a small bit of code that I seem to be calling in all my Unit tests.
Is there a common place to put shared unit test code that won't be incorporated into both unit and functional tests? I'd rather ONLY incorporate it into the needed files, just the unit tests.
I'm new to testing practices in general. Is it common...
Now that Rails 3 escapes all evaluated elements in views (good), but it is also escaping my flash message. And I like the occasional link in my flash message (or strong or emphasis).
A flash message:
flash[:notice] = "<strong>Bob</strong> was sucessfully checked in.<br />If you made a mistake, you can <a href=\"/scouts/#{@scout.id}/che...
On my old application(rails 2.3) I had:
myapp::Application.routes.draw do |map|
map.resources :posts, :has_many => :comments
now in my rails3 app I removed the |map| syntax
and I have
myapp::Application.routes.draw do
resources :posts, :has_many => :comments
This gives me the following error:
No route matches {:controller=>"comme...
In Rails 2.x I could look at @performed_render (see this question), but this instance variable doesn't seem to exist in Rails 3
...
Just created a new blog app using rails 3.0
my model is simple:
class Post < ActiveRecord::Base
has_many :comments
end
class Comment < ActiveRecord::Base
belongs_to :post
end
I used the commands: rails generate scaffold post title:string body:text etc.
to create these files.
Now I wanted to generated the db using:
rake db:cre...
Hello There!
I just upgraded my application from Rails 2.3 to 3 and I'm getting some
DEPRECATION WARNINGS for my before_create ,update, save, destroy etc.
Does anyone know how ot fix the issue?
These are my Warnings :
DEPRECATION WARNING: Base#before_create has been deprecated, please use Base.before_create :method instead. (called f...
Hello, I have a comments table which includes a column for user_id
I have the follow in my comments controller
def create
@commentable= context_object()
@comment = @commentable.comments.build(params[:comment])
.
.
Problem is this doesn't pass the current_user's user_id. How can I update the above to be something like cu...
How do I install "acts_as_nested_set" in my Rails 3 app?
I want to be able to add acts_as_nested_set to my model
I also want to be able to use ROOT, like this...
article.comments.roots.order
Ideas?
...
Greetings, all,
I'm working on an application in Ruby on Rails where we need to keep track of a bunch of external services for each user (for example, Facebook, MySpace, Google, SalesForce, Twitter, WordPress, etc) that the app will access on behalf of the user. For some services, we will need to store an (encrypted) username and passwo...
I'm trying to get autotest back up and running after moving my project to rails 3. After upgrading to rspec 2.0.0.beta.22, I can't seem to run autotest. I get the following:
bundler: command not found: c:/Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.0.0.beta.22/bin/rspec
even though the binary does in fact exist in that location.
...
Hi
I have an object with an attribute called value which is of type big decimal. In the class definition i have validates_numericality_of.
However if i:
a.value = 'fire'
'fire' ends up getting typecast to the correct type before the validation fires so:
a.valid? => true
How do get the validation to fire before the typecast?
Th...
Correct:
@teammates = Roster.all.sort_by(&:level)
Fails:
@teammates = Roster.all.sort_by(:level)
What does the & infront of the :level do? Does it act like a reference like in C++?
Thanks in advance
...
For some strange reason cardsets_path('my') generates "/cardsets.my" instead of "/cardsets/my". Please explain why?
config/routes.rb:
match '/cardsets/:type', :to => 'cardsets#index', :requirements => { :type => /my|public/ }, :as => 'cardsets'
resources :users do
resources :cardsets do
end
end
rake routes:
cardsets /cardsets/:...
Hi,
I have model with custom primary key:
document.rb
class Document < ActiveRecord::Base
set_primary_key "token"
end
routes.rb:
MyApp::Application.routes.draw do
resources :documents, :only => [:index, :show, :create]
end
When i create new document, i get error:
No route matches {:controller=>"documents", :id=>#<Document id:...
In Rails 3, I am having a problem accessing a helper method from within a model
In my ApplicationController I have a helper method called current_account which returns the account associated with the currently logged in user. I have a project model which contains projects that are associated with that account. I have specified 'belong...
Hi, What I use rails form helpers to build a form, input elements in that form have id attributes so they can match with their labels. The problem is this id is the something like person_first_name and not person_first_name_#{person.id} meaning if I have more than one form of the same type on the same page unexpected things can happen.
...
Hi there,
Just wondering if there's a way to run Rails tests without dropping the database. I'm currently only executing unit tests and am using the following rake command to do so: rake test:units.
Thanks for the help in advance!
Just in case this is relevant:
Rails 3
Ruby 1.8.7 (MRI)
Oracle 11g Database
activerecord-oracle_enhan...
I need to change session during one cucumber scenario.
For example
Given session name is "1st unauthenticated user"
And make some things
Given session name is "2st unauthenticated user"
And make some other things
I found a solution, but it doesn't work with Rails 3, Cucumber and Capybara. Are there any other solutions?
...