In my Gemfile in Rails I have these groups:
group :development, :test do
gem "capybara"
gem "database_cleaner"
gem "spork"
gem "launchy"
end
group :bdd do
gem "cucumber-rails"
gem "rspec-rails"
end
What does this mean?
...
I am developing a small Ruby-on-rails application. I am using 'roo' gem to open an excel file.
But rails throws an IO error while attempting to open the file. It says file does not exist.
It works fine in irb. My development machine is windows. Here is my code
file ="#{RAILS_ROOT}/public/data/import.xls"
file.gsub!("\\","/")
workbook =...
I'm implementing Factory Girl as a replacement for fixtures in my Rails app. I have several tables that I'm trying to represent using associations. However, to throw a kink into the loop, beyond just defining the associations, I also need to access attributes of the child factories from the parent.
Below is an example of what I'm tryi...
Hello I get this error when I do cap deploy:cold.
* executing "cd /var/www/myapp.no/releases/20100905130830; rake RAILS_ENV=
production db:migrate"
servers: ["myapp.no"]
[gcrdesign.no] executing command
** [out :: gcrdesign.no] (in /var/www/myapp.no/releases/20100905130830)
command finished
* executing `deploy:start'
[...
I was reading a book and it talks about a User has some more UserDetail, and so the UserDetail will have a user_id pointing back to the Users table. I kind of forgot that, does it help at all to has a field in Users table to have a user_detail_id to point at the UserDetail record?
This is so in Ruby on Rails too, that the Users table d...
Is it necessary to use db:migrate?
I have existing database, i want to write ROR classes for this and synchronize with DB.
How can I do this?
...
So that if you have a Ruby Version Manager, then you can switch to that mode first before altering the project files. (probably best)
...
Have myself confused . . .
I have a SubscriptionPlan ActiveRecord object which has an HABTM to available_to_roles.
In Rails 3 I'm trying to create a scope or class method on SubscriptionPlan to get appropriate subscription plans:
def self.available_subscription_plans(users_roles) #users_roles = Array of roles
#query to find all sub...
In Rails 2.X, I could simply copy gems into vendor/gems/gem_name, or use the rake command rake gems:unpack. Since Rails3 uses bundler, it doesn't appear to work anymore. I have found the command bundle package, but it doesn't work the same way.
Edit:
So, just to elaborate a bit on this:
The way that rails 2 worked, I could easily grep...
I'm having an implementation challenge at the moment, it basically consists of two different rails apps.
One rails app (app A) just provides a response in JSON, a record in this case for the nutrition data for one particular food ingredient.
The other app (app B) also Rails provides a front-end for users to view ingredients and match t...
I'm trying to connect to an API and retrieve the json results with my rails app, however it doesn't seem to work.
Take for example:
@request = Net::HTTP::Get.new "http://example.com/?search=thing&format=json"
When I try the url in my browser it works! and I get JSON data, however when I try that in Ruby the body is nil.
>> y @re...
Hello, I want to add a admin functionality to my webapp with Rails version 3. I want something very simple, there will be only one admin, this funcionality doesn't need a username field, just a password field. I don't know how to do it, can you help me?
Thanks!
...
I created a joined table for the purpose. Here's the code:
class CreateCategoriesProductsJoin < ActiveRecord::Migration
def self.up
create_table 'categories_products', :id => false do |t|
t.column 'category_id', :integer
t.column 'product_id', :integer
end
end
def self.down
drop_table 'categories_products'...
Hello, I have the following Rails 3 migration file db\migrate\20100905201547_create_blocks.rb
How can I specifically roll back that migration file, allow me to the do: rake db:reset, followed by rake db:migrate?
...
How do you get http://github.com/galetahub/rails-ckeditor working so you can upload image files? I don't think I'll use the s3 storage...
any help would be appreciated.
...
Hello, I'm a Rails newbie.... Here's what I'm trying to do....
I created a scaffold for notes (t.text :content, t.integer :user_id)
What I want to do now is only allow user's to view notes that they created. ie (== user_id)
In my /app/controllers/notes_controller.rb
I have the following:
class NotesController < ApplicationController...
Where can one find a list of deprecated methods, APIs, etc, in order to upgrade from Rails 2.x to Rails 3?
...
I am using this named_scope to search for products that have a description matching any word the user inputs.
E.g., Product.description_like_any("choc pret")
Will return products with names like
"Chocolate Bar"
"Chocolate Covered Pretzels"
"Miniature Chocolate Ponies"
Here's the named_scope I've written (which works)
named_scope :...
In a given html.erb file, I have
<%= render "steps_list", :post => @post%>
In _steps_list.html.erb, I have
<%= @post.step_names.each do |step| %>
Step: <%= "#{step}" %>
<% end %>
This works well with one exception. Each step is printed out as I want, but the entire array is also printed out at the end.
Step: Rinse Step: Lather...
I have a table like:
+--------+-----------+-------+-----------+
|house_no|house_alpha|flat_no|street_name|
+--------+-----------+-------+-----------+
| 1| | |James St |
| 1| | |James St |
| 1| | |James St |
| 2| A| |James St |
| ...