ruby-on-rails

"rails generate" creates new "generate" project ?

Running the command generates new rails projects: $ rails generate controller home index The above will create four new rails projects: generate, controller, home, and index\ Why is this happening? I'm using rails (2.3.5) ...

not getting a page reload when submitting a form on a page

When showing a project, the user can add a decision via a form_for and its partial. Is there some way of avoiding reloading the page and just creating the record silently? In the controller method (adddecision) I have: respond_to do |format| if @decision.save format.html { redirect_to(@project) } format.xml { head...

SSL configuration

I am trying to setup the ssl_requirement plugin. For my users controller I would like to require ssl for new and create. When I open users/new the browser redirects to https but I get an unable to connect error message. The application error log says : Filter chain halted as [:ensure_proper_protocol] rendered_or_redirected. I am not...

Recommended twitter gem for ruby-on-rails

I've found a couple of different twitter gem (for ruby-on-rails) out there: http://twitter4r.rubyforge.org/ http://twitter.rubyforge.org/ But I'm wondering if someone can rate them and provide a recommendation of either one or a new one. Thanks ...

How to safely let users submit custom themes/plugins for a Rails app

In my rails app I'd like to let users submit custom "themes" to display data in various ways. I think they can get the data in the view using API calls and I can create an authentication mechanism for this. Also an authenticated API to save data. So this is probably safe. But i'm struggling with the best way to let users upload/submi...

Problem with converting form_tag in rails

I am new to ruby and rails and I am having a problem from Beggining Ruby on Rails Ecommerce. (Yes, it's an old book). I have these 2 code sets for a view: new.html.erb: <%= form_tag :action=> 'create' do -%> <%= render :partial => 'form' %> <%= submit_tag 'Create' %> <%= end -%> <% link_to 'Back', :action => 'index' %> _form.html...

Ruby on Rails: How to sanitize a string for SQL when not using find?

I'm trying to sanitize a string that involves user input without having to resort to manually crafting my own possibly buggy regex if possible, however, if that is the only way I would also appreciate if anyone can point me in the right direction to a regex that is unlikely to be missing anything. There are a number of methods in Rails t...

Rails "Load more..." instead of pagination.

I have a list of elements, and I've been using will_paginate up until now, but I'd like to have something like "load more..." at the bottom of the list. Is there an easy way to accomplish this using will_paginate or do I need to resort to some other method here? From what I know this is a better route anyhow because then I don't need a ...

cant do port forwarding ro my webrick server to access it from the net!!

i am developing a facebook app and i am using for that facebooker plugin and webrick server. i have configured correctly my router to froward ports to my machine for 2 ports (80 and 3000) the apache server can be accessed from the net http://ip:80 amd the webrick server can http://ip:3000 , i dont understand why , please help me. ...

Is it possible to do AJAX calls in a liquid template?

I'm looking at the liquid templating language for Rails apps: http://wiki.github.com/tobi/liquid/ I'd like my users to also be able to make AJAX calls (just like the ones in rails for periodically_call_remote, observe_field, etc). Is this possible? Assuming the rails helpers can be added as filters, how will the user be able to modif...

How do I do a grouping by year?

I have a books model with a date type column named publish_date. On my views I'm iterating through the books and I want to group the books by year such that I have a heading for every year and books that were published on that year to be listed below the year heading. So by starting with "2010" all books published on 2010 would be liste...

how can i set up a uniqueness constraint in mysql for columns that can be null?

I know that in MySQL, UNIQUE constraits don't treat NULL values as equal. So if I have a unique constraint on ColumnX, then two separate rows can have values of NULL for ColumnX and this wouldn't violate the constraint. How can I work around this? I can't just set the value to an arbitrary constant that I can flag, because ColumnX in m...

How to call MySQL stored procedure from Rails?

Created a simple stored procedure in MySQL: CREATE PROCEDURE `proc01`() BEGIN SELECT * FROM users; END Start Rails console: $ script/console Loading development environment (Rails 2.3.5) >> User.connection.execute("CALL proc01") => #<Mysql::Result:0x10343efa0> Looks good. BUT, any more call to the same stored procedure via the exi...

Modeling multiple polymorphic relationships using Hibernate

Ruby on Rails has polymorphic relations which are really useful for implementing functionality such as commenting, tagging and rating to name a few. We can have a comment, tag or rating class which has a many to one polymorphic relationship with a commentable, taggable and rateable object. Also, a given domain object can choose to imple...

Pasting images in TinyMCE on rails app

Hi, I found a weird problem with TinyMCE editor. Copying & pasting images from another domain works fine but if the images are on the same domain the path are relative but not correct sometimes. I figured out that the problem is related to the rails URL scheme. Example) Images are copied from http://mydomain.com/index.html page and th...

Using Google App Engine as a Content delivery network

Hi, I would like to know if Google App Engine can be used as a Content delivery network like aws S3. I'm running a RoR app on Heroku and I would like store my uploaded files on GAE instead of s3. If it's possible what would be the best way to do it? ...

multiplayer / visitors interactions with Ruby on Rails?

I want to have interactions between visitors on my site. Imagine a chat room. It basically involves getting the data from everyone and sending it to everyone, this can be done by ajax and what not but I wonder if there is something already there in the wild that would do the heavy lifting for me. I have to say that I got very lost once...

Grails benchmarks compared to other web MVC platform (Rails, Django, ASP MVC)?

I have been searching the web for recent benchmarks measuring Grails overall performance compared to its competitors (Rails, Django, ASP.NET MVC...), but I didn't find anything more recent than a 3 years-old article with obsolete grails version (0.5). See here and here. So, starting from grails 1.2, are there any more recent grails ben...

Dynamically defined setter methods using define_method?

I use a lot of iterations to define convenience methods in my models, stuff like: PET_NAMES.each do |pn| define_method(pn) do ... ... end but I've never been able to dynamically define setter methods, ie: def pet_name=(name) ... end using define_method like so: define_method("pet_name=(name)") do ... end Any ideas? Thanks in adv...

Create a thumbnail of a dwg in in a linux environment

Creating a ruby on rails site that uses RMagick to create thumbnails for many types of images. RMagick cannot read dwg files however. I've tried a few things, looked into the Java library JDWGLib, which would probably allow me to write a converter, but it would be a total from the ground up solution, where I just need a thumbnail. Als...