ruby-on-rails

How to mixin and call link_to from controller in Rails?

This seems like a noob question, but the simple answer is eluding me. I need to call link_to in an ActionController method to spit out an HTML link. ActionView::Helpers::UrlHelper.link_to calls url_for, but this calls the AV module's version instead of the controller's. I managed to coerce this into doing what I intended by putting #...

http/proxy caching with memcached

What's the general best practice to deal with something like this.. ##Post controller def show @post = get_from_memcache end ##show.html.erb <div><%= post.body%></div> <div><%= post.created_at%></div> <div><%= post.category%></div> <div><%= Post.favorites_count%></div> The get_from_memcache return a @post object from a cache that...

anemone scrubbing a certain page depth

I am not understanding how to use the tentacle part of the anemone. If I am interpreting it right I feel i could use it to only scrub a certain page depth away from the root. Anemone.crawl(start_url) do |anemone| tentacle.new(i think but not working) anemone.on_every_page do |page| puts page.depth puts page.url e...

jQuery - Using Load & Updating the URL in the Address Bar while supporting the Back Button

I'm building a web app with jQuery & Rails. The web app loads pages with AJAX ... no page refresh. When a user clicks on a link to load a new page via AJAX, i want to update the address bar. I also want to maintain the browser's back button support. ideas? ...

Ajax observe_field not working on ruby on rails

I am trying to create some kind of search in my ruby on rails application and I want to add ajax support. I want when a user types in a search box a word, ajax automatically generates the results. And I have searched almost all internet and I couldn't find answer to following question: When I type into my text area nothing happens. It i...

simple ruby script that tests out mail lib not working, please help

Using irb the mail library worked fine, now I am creating my first ruby script. I am getting the error: testmail.rb:3:in `require': no such file to load -- mail (LoadError) from testmail.rb:3 Below is the file testmail.rb: #!/usr/bin/env ruby require 'mail' if __FILE__ == $0 Mail.defaults do retriever_method :pop3, { ...

How to add methods to a rails polymorphic association?

So, if I have a polymorphic association throughout my application, is there a way to add methods to it? For instance, if :post, :photo and :user are all associated to :rankings with a polymorphic association named :rankable, can I somehow create methods on :rankable that would then be inherited by :post, :photo or :user? My guess is th...

What tools are available to auto-format Ruby/Rails Code

I'm currently using GEdit with several plugins to do Ruby on Rails development. One thing I would like to have is a way to automatically format my source files (.rb, .*.erb, etc.) Ideally it would be something that I could call from the command line and/or GEdit. Command line tool would be nice, because I can set up a Git hook to auto-...

rails3 rake does not run my tests

In a fresh R3 app, I seem to be unable to run any tests (there are 2, the canonical functional test for "/" and another unit test I created) See this output: rails_app$ rake test --trace (in /Users/jan/portfolio/rails_app) ** Invoke test (first_time, not_needed) rails_app$ What could be wrong? What is the meaning of first_time, not_n...

How to keep Rails from Processing Large XML Post

In our rails application we have a many actions that do regular webapp actions. But, we have a single action that accepts a large XML file. I would like to keep rails from parsing the XML into params. Instead, I would like to be able to get the URL params ( /documents/{id}/action ) and then write out the xml file to a specific directory....

What to do about "PTY allocation request failed on channel 0"

I can't see to wrap my head creating an ssh key for GitHub. I had it working quite awhile back but I can't figure out what has changed. I've since removed the previous SSH keys from my GitHub account. After following the instructions several times for generating an SSH key (http://help.github.com/mac-key-setup) and testing "ssh git@githu...

Rails CSS zebra-striping rows, but in sets of three

What I know: Rails has the cycle() method that enables odd/even rows in a table to have different CSS classes. We can pass multiple classes to the cycle() method and that works great. I wanted rows which are grouped in three's; so, I used this: ...some html-table code... <tr class="<%= cycle("table_row_1","table_row_2","table_row_3","...

Rails 3 - Installation Problems...Could not find bcrypt-ruby-2.1.2

Hello, I'm working to install Rails 3 on a new MacBook Pro... when trying to get my app going, I get the following error: Could not find bcrypt-ruby-2.1.2 in any of the sources Try running `bundle install`. When I run bundle install, I get the following: ... Installing bcrypt-ruby (2.1.2) with native extensions /Library/Ruby/Site/...

Server failure: BUG gc_sweep(): unknown data type 0x0

My server keeps crashing. It is especially bad in localized parts of my app where the rest is fine. On one major page it is now happening every time. I've spent over an hour cutting out parts of code, restarting the server and seeing where it fails (i.e. whenever any segment of content is inserted), but my code doesn't seem to be reasona...

Are they any contenteditable-driven components to use in a web site ?

Hi, i seeking any inline editing solution for the web site. Suppose, i have an article, displayed on the page. To edit it, i click the "edit" button and everything, displayed in article gets "contentEditable" attribute and i can edit text, format is, as i want to, insert images etc. Is there any solution (free or commertial) to do th...

Javascript debugging difficult as browser doesn't refresh the scripts!

Hi, I'm trying to debug a Javascript written in the Mootools framework. Right now I am developing a web application on top of Rails and my webserver is the rails s that boots WEBrick. When I modify a particular tree.js file thats called with in one a mootools init script, require: { css: [MUI.path.plugins + 'tree/css/style...

Creating rails 3 gems: Gems installing successfully, but no functionality

Hi folks, I'm trying to create my first rails gem with jeweller - it's a very simple demo gem with just a "Tester" model and a "Frog" scaffold. The gem packages up just fine, gem contents "testgem" confirms the desired files are packaged into the gem, and when I "bundle install" it, everything seems to go OK & the gem is in the list of...

Sexy validator for uniqueness with :scope constraint

Hi, In a Ruby on Rails 3 application, I have invitations. Here is the model: class TeamInvitation < ActiveRecord::Base belongs_to :team validates :email, :presence => true, :format => RFC822::EMAIL validates_uniqueness_of :email, :scope => :team_id end How can I refactor the uniqueness validation to include it into the validat...

Authlogic + Openid: can create session but not register

I've been following the railscast (170) on openid + authlogic. So far, I've got everything just about working. I bumped into some trouble midway through but this was solved by using mreinsch's forked version of the authlogic_openid gem: http://github.com/mreinsch/authlogic_openid/commit/9b802c347f5addebcbce945af3b5f80b3ee7b214 Anyway, i...

Rails: How to give user a Notification or custom error page to enable cookies

When a user has disabled cookies in his browser and uses my Rails Application, he gets a error: ActionController::InvalidAuthenticityToken because seesion data can't be stored in a cooie. I know Rails has the option to disable session data or change the session store, but these are no options for me. I want to give the user a notificat...