Hi
How can I use yield for template inheritance in erb? I want to use erb in a plain ruby CGI script and want to use a base template and subtemplate like it Rails with the application template does.
I have both Rails 2.3.4 and Rails 3.0.0.beta installed on my local machine. I am using ActiveRecord in a stand alone ruby script and when I do require 'active_record' 3.0.0.beta is loaded. How can I force it to require 2.3.4 instead? (without uninstalling 3.0.0.beta)
I have installed the gem 'simple_uuid' but nothing seems to be working.
Using irb and running the following:
require 'rubygems'
require 'simple_uuid'
is fine, both return true. But running the following:
// Class added by simple_uuid
UUID.new
returns
NameError: uninitialized constant UUID
from (irb):3
from :0
I'm a ruby newbie, so don't assume much in the answers. Thanks.
Hi all, I've tried to create simple facebook app with iFrame,, but I always get nested iFrame on every I click link on my application, I already tried a solution from site http://railsrant.com/2009/10/14/creating-a-facebook-iframe-app-using-ruby-on-rails-facebooker/
it's work on Firefox and Chrome, but doesn't work at IE
Any idea or suggestion for this?
Thanks
I'm following this rdoc: http://rdoc.info/projects/ncr/background-fu
and can't run ./script/generate background after installing background-fu as a Rails plugin: ./script/plugin install git://github.com/ncr/background-fu.git
I'm getting following error:
Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- job (MissingSourceFile)
Am I missing something?
I was wondering what's the point of using Ruby (or even Python) in Cocoa application development other that not learning Objective-C (which is pretty simple language and will not take to more than few days to learn). I'm new to this and I'm interested why people do this? What are Pros and Cons.
I would love to use google document viewer, but I am dealing with sensitive documents and google's Terms state that if you use their service the document basically becomes public domain.
Are they any alternatives that will keep your content private?
FYI: I am developing with ruby on rails, it would be cool if there was a gem.
Hi,
I have just started learning Ruby on Rails.
I happened to look for prevention of DNS attacks in Rails and ended up reading about DNS, Session fixation and Cross Site request forgery in Rails?
How do you prevent all the above three attacks??
Could you suggest me a good tutorial on how to deal with attack in RoR?
Looking forward for your help
Thanks in advance
Regards,
Gautam
I don't understand how to get the columns I want from rails. I have two models - A User and a Profile. A User :has_many Profile (because users can revert back to an earlier version of their profile):
> DESCRIBE users;
+----------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| username | varchar(255) | NO | UNI | NULL | |
| password | varchar(255) | NO | | NULL | |
| last_login | datetime | YES | | NULL | |
+----------------+--------------+------+-----+---------+----------------+
> DESCRIBE profiles;
+----------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| user_id | int(11) | NO | MUL | NULL | |
| first_name | varchar(255) | NO | | NULL | |
| last_name | varchar(255) | NO | | NULL | |
| . . . . . . |
| . . . . . . |
| . . . . . . |
+----------------+--------------+------+-----+---------+----------------+
In SQL, I can run the query:
> SELECT * FROM profiles JOIN users ON profiles.user_id = users.id LIMIT 1;
+----+-----------+----------+---------------------+---------+---------------+-----+
| id | username | password | last_login | user_id | first_name | ... |
+----+-----------+----------+---------------------+---------+---------------+-----+
| 1 | john | ****** | 2010-12-30 18:04:28 | 1 | John | ... |
+----+-----------+----------+---------------------+---------+---------------+-----+
See how I get all the columns for BOTH tables JOINED together? However, when I run this same query in Rails, I don't get all the columns I want - I only get those from Profile:
# in rails console
>> p = Profile.joins(:user).limit(1)
>> [#<Profile ...>]
>> p.first_name
>> NoMethodError: undefined method `first_name' for #<ActiveRecord::Relation:0x102b521d0> from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.1/lib/active_record/relation.rb:373:in `method_missing' from (irb):8
# I do NOT want to do this (AKA I do NOT want to use "includes")
>> p.user
>> NoMethodError: undefined method `user' for #<ActiveRecord::Relation:0x102b521d0> from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.1/lib/active_record/relation.rb:373:in method_missing' from (irb):9
I want to (efficiently) return an object that has all the properties of Profile and User together. I don't want to :include the user because it doesn't make sense. The user should always be part of the most recent profile as if they were fields within the Profile model. How do I accomplish this?
This is the first time I'm creating an app using Ruby on Rails.
I would like to switch the database depending on the site which is loaded. With php I used to do a simple strpos on http host, and set the database name depending on that. How can I do this with rails?
Okay this has been lingering in my head for quite a while now.
In ruby on rails unit testing there is an exclamation mark with the assert method. Here is an example
test "No empty values to be inserted" do
product = Produce.new
assert !product.save
end
Let me know the function of the exclamation mark. Quick replies appreciated. Thanks.
I have a ruby array that looks something like this:
my_array = ['mushroom', 'beef', 'fish', 'chicken', 'tofu', 'lamb']
I want to sort the array so that 'chicken' and 'beef' are the first two items, then the remaining items are sorted alphabetically. How would I go about doing this?
Is there any command either in debugger or ruby-debug to get a list of all gems and/or plugins loaded in memory for a Rails process? I understand only the 'require' gems are loaded but I would like to quickly see what got loaded during runtime.
I created a form with scaffold that includes two datetime fields.
I replaced them with a datepicker, and now I'm trying to grab the date from within the controller.
Instead of having ruby do all the magic work with the datefields, I instead just have to fields, start_date and stop_date that I want to use, but I can't figure out how to grab them from within my controller. Hints?
Thanks!
Now , I execute the command line "rake db:migrate" on the window OS, but I got the problem in the console. it print couldn't find HOME environment -- expanding~/.ruby-uuid'`
who can help me to solve this ? Thank you and best regards!
Are there any examples on the web of how to monitor delayed_job with Monit?
Everything I can find uses God, but I refuse to use God since long running processes in Ruby generally suck. (The most current post in the God mailing list? God Memory Usage Grows Steadily.)
Update: delayed_job now comes with a sample monit config based on this question.
We need to import large amount of data(about 5 millions records) to the postgresql db under rails application.
Data will be provided in xml format with images inside it encoded with Base64.
Estimated size of the xml file is 40GB.
What xml parser can handle such amount of data in ruby?
Thanks.
Hello guys, I'm trying to add some online tests to my site and before I rolled up my sleeves I was wondering if there is any ruby on rails plugin support for such a task.
Essentially I'm looking for something that lets me add multiple choice questions. Performing the scoring logic would be an added bonus.
Any one know of anything?
I just installed Rails 3 and created my first app. The install of Rails3 + ruby 1.9 went very smoothly but I am missing the generate script in script/generate.
I have created a new app from scratch with no options to verify.
Any idea why this is happening and how to fix it?
Suppose a service written with RoR starts to use AWS S3 to store some data. What is the best library to use for working with AWS S3? Currently the main two alternatives for me are:
RightScale AWS Ruby gems
http://github.com/rightscale/right_aws
AWS::s3 http://amazon.rubyforge.org/
What are their main advantages and disadvantages? What if later service will need to use other AWS (like EC2)? What other gems do you use and why?
Thanks!
What is your experience using Ruby on Rails on Heroku in production mode?
Apart of the issue of the expensive https, do you see any drawback in the way it manages processes, memory and storage?
The people at Heroku is quite nice and I'm sure they are willing to answer my questions, but I would like some opinions in the customer side.
Hi!
I have got model Team and I've got (i.e.) team = Team.first :offset => 20. Now I need to get number of position of my team in db table.
I can do it in ruby:
Team.all.index team #=> 20
But I am sure that I can write it on SQL and it will be less expensive for me with big tables.
I'd like to implement measurement unit preferences in a Ruby on Rails app.
For instance, the user should be able to select between displaying distances in miles or in kilometers. And, obviously, not only displaying, but entering values, too.
I suppose all values should be stored in one global measurement system to simplify calculations.
Are there any drop-in solutions for this? Or should I maybe write my own?
Need a simple a way of rounding off an Image. I need the corners to be transparent. This link shows how to do it via command line:
http://www.imagemagick.org/Usage/thumbnails/#rounded
What I need is the corresponding RMagick\Ruby code... Thanks!