ruby-on-rails

Reporting Service for Amazon RDS?

I'm curious if anyone has any leads for me on this: I have a business app that we're building, that could benefit from some out of the box reporting services. Looking for reports that can be created and customized by the end user, without (too much) developer support. Think crystal reports / MS Access reports, but better and all web b...

Rails parses jQuery quotes wrong

I'm using Rails 2.3.8 and have a jQuery AJAX form using posted using: jQuery.fn.submitWithAjax = function() { this.submit(function() { jQuery.post(this.action, $j(this).serialize(), null, "script"); return false; }); return this; }; If I try to post a text that has quotes in it such as 1 "2" 3 Only what is inside the ...

Weird CSS problem :Missing Inline CSS : ActionMailer Attachment

My ActionMailer involves generating a report and,storing it into a HTML file and sending it as a HTML attachment. I wanted to give it some styling , so I added inline styling that gets written into the HTML file everytime the report is generated . But the styling does not reflect in the attachment. Interestingly, the generated report wh...

A Faster / More Scalable Approach to Twitter OAuth Dance in Rails?

I'm running a Rails app on the Heroku Stack (complete with Memcached, DJ Asynchronous workers, MongoDB persistent storage). Right now we use Twitter Oauth as the only authentication option on our site. (We plan to branch out to FB connect, OpenID, and/or Email/password eventually). Ruby/Rails apps, as you probably know, don't support c...

Unknown action No action responded to show

I generated a model User using scaffolding script/generate scaffold user username:string crypted_password:string email:string active:boolean perishable_token:string persistance_token:string Then I added a method in UsersController def test end And then created a view file test.html.erb and I am printing "Hello" So now I am trying ...

Organizing partials for a polymorphic resource

I'm looking for how others typically organize their partials for a polymorphic resource. Example: I have Image which is polymorphic and depending on what is imageable, I want to display things slightly different. I have a partial images/_image and can call render imageable.images. My current mindset is to have my image partial check w...

Authlogic with facebook connect

I have successfully integrated facebook connect in my rails app with authlogic. The problem is that if try to update the profile details of the facebook user there is a validation error that the password field cannot be blank. To solve the above issue, I added following to the User model. before_validation :update_authlogic_config ...

RoR: Too many queries

Hi, My problem is the following: I have the models events and music_types, connect via hmabtm join table. If I call now MusicType.all in my event controller I get a complicated query for each music_type I have. Similar to: SELECT music_types.id FROM music_types INNER JOIN join_events_music_types ON music_types.id = join_event...

Are helpers really faster than partials? What about string building?

I've got a fancy-schmancy "worksheet" style view in a Rails app that is taking way too long to load. (In dev mode, and yes I know there's no caching there, "Completed in 57893ms (View: 54975, DB: 855)") The worksheet is rendered using helper methods, because I couldn't stand maintaining umpteen teeny little partials for the different sor...

rails increment on no error

I have a rails code that sends emails. Following is in my controller: def create @users = Users.find(:all) @sub = params[:sub] @body = params[:body] @index = 0 @users.each {|i| index++; Notifier.deliver_notification(@users.email_address, @sub, @body, @users.unsubscribe_link);} flash[:notice] = "Mail was sent to ...

How to run Ruby and GIT commands in one place on Windows

I have Ruby and GIT installed on my windows box. To run GIT commands I am utilizing the GIT Bash. To run Ruby commands I am using the command line. I have not been successful running GIT commands from the CMD line nor can I seem to run Ruby commands from inside the GIT Bash. I would love to be able to run commands for both GIT and Ruby ...

Ruby 1.9.2 under RVM and MySQL already initialized constant warnings

When running Rails 3 RC with Ruby 1.9.2.rc2 under RVM I keep getting a very large number of errors from the MySQL driver bundle that look like this: /opt/local/rvm/gems/ruby-1.9.2-rc2/gems/mysql-2.8.1/lib/mysql_api.bundle: warning: already initialized constant MysqlRes /opt/local/rvm/gems/ruby-1.9.2-rc2/gems/mysql-2.8.1/lib/mysql_api.bu...

Multiple periodically_call_remote calls not behaving as expected

I've been doing ruby and rails for a long time but am a newbie when it comes to the more dynamic elements (currently jrails and jQuery), so it's entirely possible I'm missing something. That said, I've got a page where multiple elements need updating from multiple sources. For example, a dynamic header comes from one source and 5-6 d...

Ruby - Initializing a model

I don't know how to initialize information in a model before it is saved. For example. I have a model called Car, and it has the attributes wheel_size, color, etc... I want to initialize these attributes depending on other factors for each new car. This is how I'm doing it right now. Class Car < ActiveRecord::Base before_save :in...

How does one comment in an erb template?

I have some trivial markup that looks like the following: <li class="someclass"> <=% t'model.attr' %> </li> Is there a trivial way to comment that out? Just wrapping <!-- --> around the block will still leave the ruby code available to the template. This means I have to comment out the HTML and Ruby specific code separately. What's...

Ruby on Rails: named scope with lamda and an array.

named_scope :all_public, lambda { |users| { :conditions => ["visibility = ? || (visibility = ? && user_id = ?)", Shared::PUBLIC, Shared::PRIVATE, users] } } that works nice for one user, but is there a way to modify it to work where users is an array of user ids? ...

Ruby on Rails 403 Not Found

I am trying to get a simple demo of Ruby on Rails working on my local version of Apache (Mac OS X 10.6). I have a folder in the localhost linked to the public folder (/Users/david/Sites/demo/public to localhost/demo), I have permissions set to read write execute for the group and the group set to _www. I have the directory set to: <Dire...

Difference between differnet web programming frameworks?

I have experience programming dynamic websites using both php and perl driven CGI code, (both on apache web server on *nix systems, though that shouldn't matter). I do not have too much exposure to other technologies for web creation, but I frequently hear hailing and railing towards them from all forms of developers. (The most I've he...

rcov + Rails3 rc now broken from linecache dependency

I hit a wall today with rcov + Rails3. I am developing my Rails3 app using Ruby 1.9.2-preview3. rcov and relevance-rcov do not work with Ruby 1.9.2 yet. I can't find any fork of rcov that does yet either. It wasn't that big of a deal since I could easily switch over to Ruby 1.8.7 using rvm --default 1.8.7; rake test:coverage. So the...

Ruby on Rails / MySQL: how do I do a search on an array using OR?

Both privacy and users are arrays. I've taken out some logic to show the important stuff. named_scope :non_employees_and_beloning_to_users, lambda { |args| privacy = args[0] users = args[1] { :conditions => ["(visibility = ? && user_id = ?)", privacy, users] } } but basically, the above generates the below, and when t...