ruby-on-rails

Rails Page Caching with a hits/views counter. How?

Hi, I want to use rails page caching to speed up a application which encounters heavy load. But I also need to count the hits/views on the objects presented. So I have the model "Article" with a unique hit counter method (by IP) which is called every time the user hits the show action. That doesn't work with caching, so I'm wondering ab...

validation of special characters

I want to validate login name with special characters !@#S%^*()+_-?/<>:"';. space using regular expression in ruby on rails. These special characters should not be acceptable. What is the code for that? Thanks, Pallavi ...

This is right way for database?

Hello, i have some issue with database. Okay, i have two models -> Page and Item. Page for displaying some content. Item -> this is item discription. So, i work on small ecommerce shop. Okay, all of this models can have some comments. So, this is my Comments model at this moment: Comments -> string : id text : body integer : page_i...

Is there a way to authenticate a user to LDAP with email/password?

Is there a way to authenticate a user to LDAP with email (mail) and not cn or DN? We are using ruby ldap, and possibly active-ldap (we have been having problem with it, though). All we need to do is authenticate a user and then create a membership in our system based on the authentication success. ...

rails helper to create a valid URI (with escape characters)

Dear experts, is there any existing rails helper to create a valid URL? Specifically, I am generating a Web URL with some parameters that having special character (for e.g space i need to convert into + , and many others special characters). http://domain.name?param1=ABC+DEF&amp;param2=GHI Thanks. ...

Rails, Passenger and Memcached: Unable to find server during initialization

Hello, I hope all is well. I am hoping someone can help me with a problem that I am certain is user error? The configuration details below work in all my other environments including integration, development and qa. However, the production servers give the following error: unable to find server during initialization. When I telnet to...

Unique responses rails gem

I like to determine if a visitor has already submitted a form. I was thinking of doing a couple of things: cookie ipaddress requiring login (much less desirable since the signup barrier might dissuade visitors) Is there a ROR gem for this? If so please post a link. Thanks ...

Finds in Rails 3 and ActiveRelation

Guys, I'm trying to understand the new arel engine in Rails 3 and I've got a question. I've got two models, User and Task class User < ActiveRecord::Base has_many :tasks end class Task < ActiveRecord::Base belongs_to :user end here is my routes to imply the relation: resources :users do resources :tasks end and here is my ...

Attachment_fu error

Hello, I am getting an error while trying to upload images on an Ubuntu machine that's running Rails 2.3.4, Ruby 1.8.6 using attachment_fu with image science. FreeImage exception for type ???: IPTC: Invalid key 'Tag 0x025C' The error seems to point to this line in the image_science_processor in the attachment_fu plugin: def with_imag...

How to insert rows in a many-to-many relationship

Hello, I am having an issue trying to save into an intermediate table. I am new on Rails and I have spent a couple of hours on this but can't make it work, maybe I am doing wrong the whole thing. Any help will be appreciated. =) The app is a simple book store, where a logged-in user picks books and then create an order. This error is ...

What's a good plugin or guide I can use to create javascript widgets from a Rails App?

I've been looking around for a while now and the best guide I've seen so far is Dr Nic's DIY widgets how to (here). I haven't been able to make something like this work: Assuming this is my widget code: <script src="http://mysite/nomnoms.js"&gt; </script> And my nomnoms controller looks like (assume that the list partial exists and...

Possible to embed markdown within erb?

If you use haml as rails view template, you can write portion of your page using markdown by using the ":markdown" filter. Is is possible to do the same using erb? ...

ImageMagick is not processing images, but gives no errors.

My problem is is that paperclip saves the attachments appropriately, and I assume imagemagick is doing something right. With no errors returning, the images never finish processing. Does anyone know a way to see what's backgrounding? Or specifically a way to review imagemagick's processes? ...

How do I use link_to_remote to pass then render a partial in rails?

I want to create several link_to_remote links that are campaign names: <% @campaigns.each do |campaign| %> <!--link_to_remote(name, options = {}, html_options = nil)--> <%= link_to_remote(campaign, :update => "campaign_todo", :url => %> <% end %> I want the output to update on the page to render ...

Rails mysql Type Error after switching to Ruby 1.9.1

I'm not quite sure how to go about diagnosing this issue, after switching my app to Ruby 1.9.1 I'm getting this error: TypeError wrong argument type Mysql (expected Struct) And it seems the app fails to boot, so I'm not really sure of how to even begin solving this issue. I've made sure all my gems are up to date and they are. I'm us...

What are the most important things to know about Ruby?

I am new to the language and I need to know what are the top things that are absolutely necessary to know in order to make a fully functional website or web app using the Ruby programming language? Mainly Ruby on Rails with Rake and other tools that mainly use Rake. Update: I know many other languages like C++, Java, PHP, Perl, etc, et...

How to make ActionController::Base.asset_host and Base.relative_url_root independent?

In our Intranet environment we have a decree that common assets (stylesheets, images, etc) should be fed from Apache root while Rails apps runs from from a "sub directory" (a proxy to a Mongrel cluster). In other words: <%= stylesheet_tag '/common' %> # <link href="http://1.1.1.1/stylesheets/common.css" /> <%= link_to 'Home', :contro...

Rails toggling closest submit button in a form with radio buttons

I have a bunch of forms listed in Rails like such <% parent.children.some_named_scope.each do |child| %> <% form_for :parent, parent do |f| %> <% child.possible_values_for_column_to_set.each do |value| %> <% f.fields_for :children, child, :child_index => child.id.to_s do |child_form| %> <%= child_form.label :co...

Ruby on Rails: how to display an HTTP 500 in XML?

I want to be able to display an HTTP 500 error with an XML builder template if the request Accept type is asking for XML. By default it displays 500.html, even if the request type is not asking for an HTML response. ...

In Rails, how to respect :scope when using validates_uniqueness_of in an embedded object form?

I have a Book model, which has_many Chapters (which belong_to a Book). I want to ensure uniqueness of Chapter titles, but only within the scope of a single book. The catch is that the form for creating chapters is embedded in the Book model's form (The Book model accepts_nested_attributes_for :chapters). Within the Chapter model: va...