ruby-on-rails

How to add 'auto_increment' to another column besides 'id' in rails table defination?

If I need to add 'auto_increment' to a new column called 'another_id' in a table, how can I make it? Is there an option like: create_table :posts do |t| t.integer :another_id, :auto_increment => true # Is there a option like this? ... t.timestamps end In development env I use sqlite3, and mysql in production env; ...

scriptaculous slider for rails - basic use?

I'm trying to use the scriptaculous_slider plugin for rails. I don't understand the documentation. Here's the example they give: Example: <%= slider_stylesheet %> <%= slider_field :object, :method, :range => 1..10 %> My use case is pretty simple. I have an object todo_item and I want to set a slider to change the value of the...

rails application fails to start

I am trying to setup my rails application on my vps running ubuntu 10. I am using passenger with apache to run my app. When I try to go to my application url, I get the error, "ruby (rack) application could not be started. Missing rails 2.3.8 gem" I have the gem installed. So, to debug a little more, I put a print statement in boot.rb t...

Creating a new rails application in rails 3

in the previous rails versions you ran rail whatevertheappsname -d mysql what is the new way and how do you generate scaffolds and controllers/migratations ext.. ...

Where to put ruby object extensions

Hi, I would like to know where put monkey patching code like the following in my rails application which would open up existing classes and add or override new functionality. I want this code to be available to all instances as soon as possible. Is autoload the correct way of doing this and putting the call in environment.rb? class C...

Installing Ruby on Rails for Windows 7 (up to date)

I'm a designer and not a coder and having issues with the first install. I downloaded Rails 1.8.6 and Instant Rails. I opened a console and tried updating gems. Nothing worked there. I think I will just delete everything and start over because I'm sure I broke something by now. I was really thinking about buying a Mac today just to ge...

Why getting error: Object#id will be deprecated; use Object#object_id

On my local development rails environment, I am able to check the output from a SOAP call just fine. I can use response.id to get the value from this packet displayed using the .inspect method: #<SOAP::Mapping::Object:0x15702d0c0604 {}id="dd26ce5f-0cfd-9bbb-3485-4c64c9d6378 4" {}error=#<SOAP::Mapping::Object:0x15702d0bf6f0 {}number="0"...

Problems with routing and path

Hello, I am new to rails and I have a weird problem i don't understand... I have created a basic application with only one controller. this controller is name routes (for testing purpose...) and it contains index, new and edit actions. I have added a resource in the routes.rb file: map.resources :routes The problem I have is when i...

How do I create a form that submits two dates and outputs the report?

I currently have a controller which produces a report. This is the controller: def last5days #@monday = (Time.now).at_beginning_of_week @monday = (Time.now).months_ago(1) #@friday = 5.days.since(@monday)-1.second @friday = (Time.now) @sent_emails = ContactEmail.all(:conditions => ['date_sent >= ? and date_sent <= ...

Converting PDFs to be viewed in any browser

I currently use a PDF-to-Flash to allow for users to flip thru pages of uploaded PDFs. However, with so many using iPhones/iPads I would like to switch this to a solution which works with any browser. The site is developed in Ruby on Rails and I have looked into using pdf-toolkit and rmagick to convert the PDFs to images but it's not en...

render text but still get a missing template error.

def r_return if var begin User.transaction do #code here end render :text => html return rescue => e #rescue here end else redirect_to root_path end #it has to been render at the end? #render :text => html end what's the wrong with my code? can't render it a begin...end block...

Fastest rails test runner: spork and zentest?

I ran across a thread about slow rspec tests that made me wonder which rails test runner configuration will result in the fastest running recurring tests? I'm aware that ZenTest / autotest-rails can be used in conjunction with spork, but is that the fastest option? ...

Factory Girl created objects not clearing in between tests?

I'm being held up implementing tests with a slight confusion. With User.create I can create and save in multiple tests: should "test something" do u1 = User.create(:first_name => "Fred", :last_name => "Flintstone") assert true end should "test something else" do u1 = User.create(:first_name => "Fred", :last_name => "Flintstone")...

Simple validates_length_of yields unexpected NoMethodError

I have a message form which uses validates_length_of in the model to limit the length of the message. validates_length_of :content, :maximum => 1024 I "tested" this by entering 5k or so characters and submitted the form. But I get this NoMethodError: NoMethodError in Messages#create Showing app/views/messages/_messages.html.erb w...

Resolving URI character encoding issues in Rails

I'm working with a Ruby on Rails application that makes a client side API call to a 3rd party service. It then takes strings from the 3rd party API and generates URIs with them. Unfortunately, Rails fails to parse some of the URIs due to encoding errors. I have tried running the strings through encodeURIComponent, but this does not reso...

new/edit actions on show page :: best practice question

i am designing a dashboard page that summarizes data from multiple models, all on one page. and i also want to include forms on that page for creating new items. after some experimenting, i realized i needed some advice as to the best practice for this situation... here are the 2 methods i was attempting 1) using nested field_fors... ...

Rails PDF Prawn Data Generation from controller

I have a file named report.pdf.prawn, which is the view part of my PDF file where we can edit the contents of the PDF file like >>> *pdf=Prawn::Document.new(:page_layout =>:landscape,:page_size => 'A4') pdf.text"Hello" head=@headers headers=[""],[""] pdf.table headers, :width => 768, :size => 11, :border_style => :underline_header, :he...

Why does Mac OS X come with ruby/rails?

Why does Mac OS X come with ruby and ruby on rails pre-installed? Does the OS actually use it at all? Can I update my Ruby, Rails or Gem versions safely without something spitting the dummy? ...

Ruby on Rails database.yml information

I'm a designer and brand new to programming. I have just opened my localhost and can see "Welcome aboard". It has 3 steps to complete - all of which simple to most, are complexing to me. config/database.yml ok it wants to know my username and password. Where do I get these and where do I post them to to get them to work? I opened my d...

Using Cucumber to test my OAuth provider in Rails

I have a rails site that allows authentication through OAuth (I use Restful Authentication and the Rails OAuth Plugin). To make sure that it worked, I made a quick site to act as an OAuth consumer. However, I want the testing to be self-contained in Cucumber features. Ideally, this would use Webrat so that Cucumber could correctly m...