ruby-on-rails

maintaining a SOAP session in Rails

I'm writing a Rails application which need to maintain a session to a SOAP-based web service, but I'm running in to difficulties between SOAP/REST. After logging in I get a session token, which must be provided in subsequent requests. I can initiate a connection (including logout) every time, but it seems like a huge amount of overhead...

How Do I Use Factory Girl To Generate A Paperclip Attachment?

I have model Person that has many Images, where images has a Paperclip attachment field called data, an abbreviated version displayed below: class Person has_many :images ... end class Image has_attached_file :data belongs_to :person ... end Person is required to have at least one Image attached to it. When using FactoryGi...

rails -- Add div (popup) to flash[:notice]

Hello. I have a flash[:notice] = "Thanks for signing up!" I would like to add a link that activates this modal popup window I have with javascript. The code for the popup is <div> <a rel="group" class="group" title="Title 1" href="/images/screencap1.jpg" >Find out how to use us</a> <div style="display: none" > <a rel="group" class=...

deployment for jruby on rails app

I am trying to deploy a jruby on rails application. Right now I am running mongrel + Apache2 using reverse proxy from mod_proxy. However, because mongrel_jcluster does not work for the latest versions of jruby, I am only able to run one mongrel server, and cant take advantage of load balancing from apache2. Is there any way other way ...

Rails: Does this belong in the model or controller?

I have a method which runs several rake commands. Does this method belong in the controller or in the model? My intention is to run this method upon every Save or Update ...

In Ruby on Rails, how to make HTML as partials in one file and Javascript in another file to be included last?

A lot of time, in a partial, the HTML (or ERB or HAML) as well as the Javascript is in one file, so when the main file includes these partials, the HTML will be intermixed with Javascript code. However, it is said that for fast page content display, all Javascropt code should be placed at the end of the HTML file. In this case, is ther...

Internet Explorer uploading file data as a String in Rails 2.3.4

Some random IE users (versions 6-8) aren't able to upload files. The data that comes in the POST is a String instead of a File object. Has anyone seen this and have any insight into where the issue may be? Valid upload: attachment_data: #<File:/tmp/RackMultipart7719-0> Invalid upload: attachment_data: "Soccer profile.doc" [UPDATE] ...

Will caching work if one of the web servers has a clock that is slightly off?

It is said that the web servers' clocks must be identical for the Expires and Cache-Control headers to work? Why is that? Can't they be off by 1 second or a few minutes? If the cache is supposed to be good for 1 year, then won't a time difference of a few minutes or even a few hours not matter on one or some of the web servers? In ht...

Rails date_select helper and validation

I have a date field in a model backed form in my Rails App: <%= f.date_select :birthday, {:start_year => Time.now.year, :end_year => 1900, :use_short_month => true, :order => [:month, :day, :year], :prompt => {:month => 'Month', :day => 'Day', :year => 'Year'}}, {:class => 'year', :id => 'user_birthday'} %> It is being v...

What are the components of Ruby on Rails that I need to understand?

Hi, I've been going through this online rails tutorial: http://www.railstutorial.org/ I highly recommend it if you want to get an overview of what rails does and some best practice methods. But now, as I do my first application, I am having trouble isolating parts of Rails that I need to understand and learn. My question is: What are t...

show.html.erb format help

Okay so I am working on making a site for my previous boss who runs an animal control business. My index.html.erb consists of code like this: <div id="bats"><img alt="Big brown bat" src="/images/bigbrown.png" style="position: relative; border: 0.25em outset;" /> <p class="text_center"><%= link_to @animals[0].name, animal_path(@animals[0...

What is the best way to allow website users to edit already existing database records?

I am building a web application that will essentially allow authenticated users access to mass amounts of data, but I don't want users to only have read-only access. If there are records missing fields but a user has found information to fill these fields or correct already populated data, I would like the user to be able to do so. Howe...

Problem with file uploads in a nested form using Rails3 with Mongoid and Carrierwave

Im having a problem transferring an SQLlite Rails 3 app over to a Mongoid Rails 3 app. In the SQLlite version, I am easily able to include an image upload form (using Paperclip) from one model ('image') within a nested form from another model ('product'). Here's my 'new' product form: <%= form_for @product, :html => {:multipart => t...

syntax error, unexpected ':', expecting $end

I am attempting to get this going: http://github.com/xaviershay/db2s3 I created a file in config/initializers/db2s3.rb DB2S3::Config.instance_eval do S3 = { :access_key_id => 'id', :secret_access_key => 'key', :bucket => 'name' } end In the rake file I added: require 'db2s3/tas...

How do I store keys for API's in Rails?

I have several api's that I am integrating with and need to call in various parts of my application. What is the way to store the keys, the user/password, or token information, say, a configuration file and then how do I call them for use in other parts of the application? Thanks. ...

Regex Pop Quiz Question of the Day

Suppose I want to turn this : http://en.wikipedia.org/wiki/Anarchy into this : en.wikipedia.org or even better, this : wikipedia.org Is this even possible in regex? ...

Rails 3 and FCGI?

I want to make an app for a friend but he has shared hosting and the only option is fcgi and I can't find any documentation on how to do it. Is there anyways to run rails 3 on FCGI? ...

How do i get swfupload to return image URL after upload?

I am facing a really weird problem. I am using swfupload to upload multiple images to the imageshack server. I am also storing the returned URLs in the database. How do i show the URL returned from imageshack to the user as soon as i receive it? Is there any way to make swfupload return the URL once upload finishes? Here is the code that...

Rails Private / Public Message Toggle

Hi, I'm not quite sure how to go about framing this question, but I am building a social network from the ground up using rails; one feature is twitter style messages. I am trying to create an option that when the user submits their message, the have a checkbox that says "private". If the checkbox is checked, only the users friends can ...

comparision of date in ruby

how to compare particular date with today to know whether that paricular date is greater than today Thanks Harish. ...