ruby-on-rails

article table schema

I need to create the typical crud app for "articles", is there a standard or sort of a best practice when it comes to this? I know every app and situation varies, but I mean generally. Secondly, I'm confused a bit on how to handle multiple images associated with a particular article, I was thinking just img tags strewn through out the b...

Create a website screenshot/thumbnail server-side?

I'm building a rails app that needs to grab and display a thumbnail screenshot from a URL. I'm having a difficult time even finding where to start. Any help would be greatly appreciated. Thanks. ...

Ruby Gem Calendar Date Select

Hey, I'm having trouble with the time portion of the Calendar Date Select gem. The following code limits the date to any day after/greater than today. I need to do this for time, limiting the user to a time that is 24 hours or greater than from now. I can't figure out if the code used in the :valid_date_check is SQL, or Javascript or wha...

Rails testing with Selenium and everybody has a wrong password

I have an application with a bunch of cucumber tests, and I tried using selenium with it today. It took a bit, but I got it running, it starts up selenium, uses the correct database and everything, but everybody has a wrong password. I can see the user getting created, I can log the password and see that it's the correct password, but e...

How can I process data to avoid MySQL "incorrect string value" error?

I am trying to use a Rake task to migrate some legacy data from MS Access to MySQL. I'm working on Windows XP, using Ruby 1.8.6. I have the encoding for Rails set as "utf8" in database.yml. Also, the default character set for MySQL is utf8. 99% of the data is coming in fine, but every now and then I'll get a column value that gives me...

Easy to use Isolated widgets on rails

I am developing a "game platform" on ruby on rails. It is not a 2D or 3D intensive game but more like quiz games, imagine typical Facebook quiz or even "how big is your brain" kind of games. The platform will be used by students here to develop easily their own ideas. The point is to create a series of widgets they can just place in the...

Presenting Deeply Nested Resources Administration

Hello: I'd like to get some ideas on how to properly present deeply nested resources in CRUD operations. Let's say I have 4 levels of nested resources (resource 1, resource 2, resource 3, resource 4). I'd like to present the user with easily navigatable, non-confusing interface to allow them to navigate along the tree or to adjacent re...

Discrepancy between System and Db times

I have a rails application and I store all time in UTC in the database for TimeZone differences' purposes. I also expire a record instead of deleting it by setting "effective_end_date" field in the table to current time. Then I use named scope as follows in the model: named_scope :valid, :conditions => ['(effective_end_date IS NULL OR...

Rails RESTful resources using to_param for a field that contains separator characters

I want my Rails 2.3.2 app to respond to and generate URLs like so: /websites/asd.com /websites/asd.com/dns_records/new In my config/routes.rb, I have: map.resources :websites, :has_many => :dns_records map.resources :dns_records, :belongs_to => :website I can then access resources such as: /websites/1 /websites/1/dns_records By ...

Rails swfupload and apache configuration issue

I am trying to use swfupload with rails . I configured everything , passing the session_id and authenticity token in the URL and it works great on my local environment ( webrick ) . However when I deploy it on production with Apache , everything works fine except the swfupload . I keep on getting 301 error code . After trying http sn...

How can I use % in a :conditions argument to ActiveRecord.find?

I'm trying to do a query like this: Widget.find(:all, :conditions => ["name like %awesome%"]) However, I'm getting a "malformed format string" exception from sanitize_sql, specifying the "%" as the problem. How can I perform this query? ...

Uploading image problem (Insoshi RoR framework)

Sorry if this problem might be a little too specific. I'm a RoR newbie still. I'm currently modifying an RoR app based on the Insoshi framework on windows vista. It uses Free Image and the image_science gem along with attachment _fu for uploading images to the application and resizing it. Every part of the application seems to be up and...

Validation groups for wizard-style forms

Hello, can somebody explain me, how to do wizard-style forms with validations? f.e.: i have a appointment-model, which should include following data: name, starttime, endtime, address, city. Now i want to have 3 actions for each datagroup: name start and enddate address-fields each of them should be accessible (so AASM isn't a...

validate at least one in has_and_belongs_to_many

I have a model with: has_and_belongs_to_many :users How do I validate that the model has at least one user in the model? I tried: validates_presence_of :users But that doesn't seem to give me what I want... ...

Routing problem

Hi all, I'm trying to create a user managment system where users can be dragged and dropped along different groups (copy and move users). I use drop_receiving_element "move_drop_zone_1", :update => "users", :url => move_user_path(:target_node_id => node.id), :method => :put, :accept => "move_user", :hoverclass => "node-ac...

Nested model parameters during an HTML post

I'm been playing with calling my rails controller using an HTTP POST. I can get it to work with a curl command such as this, given a model named item and an attribute in that item called name: curl -X POST -d "<item><name>myname</name></item>" -H "Content-Type: text/xml" http://localhost:3000/items.xml What I'm curious about is how t...

Using RJS to Replace Div

I currently have a link which when clicked calls a JavaScript function, which gathers some data and then uses ProtoType to submit a form... function myFunction(){ data = someobject.getData(); $('myform').request({ parameters: {data:data, id:id,}, onSuccess: function(transport) { document.location.reload(); ...

acts_as_xapian jobs table

Hi, Can someone explain to me the inner workings of acts_as_xapian_jobs table? I ran into an issue with the acts_as_xapian plugin recently, where I kept getting the following error when it creates an object with xapian indexed fields: Mysql::Error: Duplicate entry 'String-2147483647' for key 2: INSERT INTO `acts_as_xapian_jobs` (`act...

send parameters from drop_receiving_element

Hi all, users can be dragged to nodes to move or copy a user from one node to another node. I have a problem with how I send the variables to user move and copy methods in userscontrol. The drop zone is defined as: <%=drop_receiving_element "move_drop_zone_"+node.id.to_s, :update => "users", :url => move_user_path(:id => node.i...

Best javascript libraries to work with rails?

I want to develop an application with simple Quiz-like games (think of a question , answer, a timer, high-scores/ranking, not much more) For that I want to use Rails and some javascript library that let me have some modern effects on the GUI (being a GUI the least you can ask is for an atractive interface) I first considered ExtJS but ...