ruby-on-rails

How to proxy files from S3 through rails application to avoid leeching?

In order to avoid hot-linking, S3 bandwidth leeching, etc I would like to make my bucket private and serve the files through a Rails app. Concept in general sounds very easy, but I am not entirely sure which approach would be the best for the situation. I am using paperclip for general asset management. Is there any build-in way to achi...

In Rails, why do .sass files magically get recompiled into .css files?

I didn't invoke any sass command to "watch" the .sass file changes and recompile them into .css (and concatenate all .css into a giant .css file) But somehow, when I modify any .sass file in the Rails project, and reload the page on a browser, the giant .css file already has the updated content. What is the mechanism that does this? ...

how exactly do I install restful authentication plugin in rails 3 ?

I'm very confused on this restful authentication plugin on rails 3. I tried to install the plugin using the following command. It tells me it's already installed, then I tried to use the --force to reinstall this plugin it tells me that the plugin not found So if the plugin is already installed why do I get error Could not find generat...

How can I authenticate with an existing LDAP server with authlogic_ldap using Rails?

I am working on a corporate intranet site and need users to be authenticated prior to using the rails application. I have experience using auth_logic, but in this case I don't care about creating/editing/deleting users, simply authenticating them. I found that Ruby Toolbox (http://ruby-toolbox.com/categories/ldap.html#binarylogic_aut...

What is wrong with my div_for?

I can figure out why this simple code would not compile. May be fresh eyes will see what I am missing. <table> <tr> <th></th> <th><%=h "Name <Email>" %></th> <th>Role</th> </tr> <% project.participations.each do |participation| %> <tr> <%= div_for(participation) do %> <td>some stuff</td> <td>more ...

Moving object graph between a new iPhone app and a new Rails 3 backend

I know this question has been answered a million times over the years... but times, and technologies, change quickly...so looking for "fresh" data ;-) I'm seeking advice on a robust, and relatively straight forward, approach toward moving fairly complex objects from a Rails 3 back-end to an iPhone 3(4) app. There is no pre-existing API ...

rails 3 destroy action fails

The destroy action: def destroy @tag = Tag.find(params[:id]) @tag.destroy respond_to do |format| format.html { redirect_to(tags_url) } format.xml { head :ok } end end The link: <a href="/tags/14" data-confirm="Are you sure?" data-method="delete" rel="nofollow">Destroy</a> Clicking it renders the show action. Star...

What does `lib` mean in the config.gem call in environment.rb

I see a command in environment.rb that says config.gem 'thoughtbot-paperclip', :lib => 'paperclip', :source => 'http://gems.github.com' If I wanted to manually do it, it would be gem install thoughtbot-papperclip --source http://gems.github.com Where does the lib fit in to the command line gem call? ...

Is there a Ruby on Rails based torrent tracker?

I'm looking for a torrent tracker written in Ruby on Rails (TBDev.net style or so). Is there a ready made package? Another option: Is there a robust torrent tracker software that can act as a backend for which I can write a RoR front end? ...

Customize Facebook url in Authlogic-connect

I'm using Authlogic Connect for Authlogic and I can't figure out how to customize the facebook url. By default it sets the display param to page display=page and I want to have it set to page=popup. I've been stepping through the code but I haven't been able to figure it out. Any ideas on how to customize it? ...

Creating Surveys with accepts_nested_form_for

Hello, I have been working with rails3 and have been trying to create a simple survey application but some issues have come up. I can create questions just fine but when it comes to creating a survey that people can take I come accross some issues. For one the answers aren't being assigned a :user_id or :survey_id. The following is a co...

rails way user to user messaging, do I need a join table?

Quick question (I think). I have users, and I would like to allow them to send messages to one another. My question is, should I have a user table, a message table, and a users to messages join table, or should I just store to_user_id and from_user_id in the messages table. If the latter, what would the association look like for that? ...

Using class function from the lib directory in rails

Hey! I am creating a rails3 application and I want to create a class that handles string formatting, so I made a class called FormatUtilites.rb in the lib directory but whenever I try calling it from somewhere else in my app I get this error: ActionView::Template::Error (uninitialized constant ActionView::CompiledTemplates::FormatUtil...

Differences in putting a module in /helpers or in /lib?

What are the reasons putting a module in /helpers over the /lib folder in a RoR app? Are /helpers more controller specific, while the /lib is more general in nature? ...

to_json :include :order ?

Is it possible to order included models? format.json { render :json => @client.to_json(:include => { :videos => { :order => 'sortorder' } }) } ...

Matching input tag with Cucumber/Webrat

I'm learning Cucumber, but I can't make a step for just matching input tags. What I have in the view is <input type="submit" value="Press!" /> And what I tried in Cucumber are Then the "input" field should contain "Press!" Then the "type" field should contain "submit" I just wanna confirm the existence for the input tags with cert...

Rails - Understanding how to create methods?

Hello, I'm creating a observer model: booklogger_observer.rb The observer model looks a little something like this: class BookLoggerObserver < ActiveRecord::Observer observe :book def after_create(record) @logitem = ......app specific stuff @logitem = ...... @logitem = ...... assign_meta(@logitem) @logitem...

[newbie ] How to install ruby interface for sqlite3 in Mac snow leopard ?

I tried to install it as below but it throws error :- "sudo gem install sqlite3-ruby" Building native extensions. This could take a while... ERROR: Error installing sqlite3-ruby: ERROR: Failed to build gem native extension. /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb mkmf.rb can't find header files ...

Rails: How do I call `self.save` in my model and have it persist in the database?

I'm trying to keep model logic within my model, but I can't get it to perform modifications on itself and have them persist in the database. In my controller: @article.perform_some_calulcations! In my model: def perform_some_calculations! self.foo.gsub!(/regexp/, 'string') self.save end If I drop debugger statements into my me...

Getting intimidating looking at /config files in projects at github, is there a book that covers this?

I'm looking at some open source apps on github, specifically the files in the /config folder like: boot.rb, application.rb, etc. They seem too complicated! Is there a book that details all of this? I'm finding the basics easy to understand, but configuration, setup is always a tricky part and a solid book on these topics would be gre...