ruby-on-rails

Could you help me write a proper query in rails for accessing the following information?

@workname = [] @recos = [] @bas = [] if current_user.recommendations.size != 0 current_user.recommendations.each do |r| if r.work_type == 'J' @job = Job.find_by_id(r.work_id) @workname.push "#{@job.title} at #{@job.company.name}" else @qualification = Qual...

Rails: include index with fields_for form helper

I'm trying to build two models from one form by using the fields_for method. My code looks like this: <% for scale in @event.scales %> <% f.fields_for "scale[]", scale do |scale_form| %> <p> Scale<br /> <%= scale_form.label :name %> <%= scale_form.text_field :name %> <%= scale_form.label :price %> <%=...

What's the equivalent to django-flatpages in Ruby on Rails?

How can I build a minimal CMS like Django does with django-flatpages? I'd prefer a built-in solution to a plugin. I heard of controller caching, does anyone know of another solution? ...

Text Formatting in Ruby (For Packing Slips)

I need to generate formatted text packing slips for a Ruby on Rails project I'm working on. I'm considering using Ruport or just formatting it myself in a string and outputting it to text. The only challenge is justifying all of the output appropriately. It needs to look something like this, always aligned properly. Any recommendations? ...

Writing a simple webservice in C# and calling it from Ruby on Rails

I need to create a simple webservice in C# but I'm not sure where to start (I've coded UI apps in C# before but all my web experience is in Ruby on Rails). Where do I start? The only client for the webservice will be a Ruby on Rails app so there's no need for any HTML rendering. I was thinking of just returning a XML or YAML formatted s...

Rails / ActiveRecord Modeling Help

I’m trying to model a relationship in ActiveRecord and I think it’s a little beyond my skill level. Here’s the background. This is a horse racing project and I’m trying to model a horses Connections over time. Connections are defined as the Horse’s Current: Owner, Trainer and Jockey. Over time, a horse’s connections can change ...

rails test.log is always empty

All the log entries generated when running tests with 'rake' are written to my development.log instead of test.log file Do I have to explicitly enable logging for test in enviornments/test.config?? (I'm using 'turn' gem to format test output, Can that cause an issue?) I'm running rails 2.3.5, ruby 1.8.7 I've all these gems installed f...

Smartest way to import massive datasets into a Rails application?

I've got multiple massive (multi gigabyte) datasets I need to import into a Rails app. The datasets are currently each in their own database on my development machine, and I need to read from them and create rows in tables in my Rails database based on the information they contain. The tables in my Rails database will not be exactly th...

Sql query Error: Operand should contain 1 column(s) in rails

Hi everyone, SELECT * FROM `jobs` WHERE (SELECT DISTINCT jobs.* FROM jobs, job_requests WHERE (jobs.user_id = 1) OR (job_requests.user_id = 1 AND job_requests.job_id = jobs.id) ) This sql gives me: Mysql::Error: Operand should contain 1 column(s). If I execute the select from the wh...

how to test workling/starling with rspec

Hi, I have put some tasks in my rails app over to a Workling worker - my question is, what is best practice to test the Workling class with rspec? I have set up rspec to be able to call the Workling class, (I use Sterling too), but since it is asyncron I dont know how to test for the result of the work done by workling. Thanks ...

Business Logic Layer Pattern on Rails? MVCL

That is a broad question, and I appreciate no short/dumb asnwers like: "Oh that is the model job, this quest is retarded (period)" PROBLEM Where I work at people created a system over 2 years for managing the manufacture process over demand in the most simplified still broad as possible, involving selling, buying, assemble, The system i...

Where can I find a free image-uploader library/service?

Where can I find an image uploader similar to the one here? I need this to work with PHP or RoR. ...

Case-insensitive find_or_create_by_whatever

I want to be able to do Artist.case_insensitive_find_or_create_by_name(artist_name)[1] (and have it work on both sqlite and postgreSQL) What's the best way to accomplish this? Right now I'm just adding a method directly to the Artist class (kind of ugly, especially if I want this functionality in another class, but whatever): def sel...

Marking multi-level nested forms as "dirty" in Rails

I have a three-level multi-nested form in Rails. The setup is like this: Projects have many Milestones, and Milestones have many Notes. The goal is to have everything editable within the page with JavaScript, where we can add multiple new Milestones to a Project within the page, and add new Notes to new and existing Milestones. Everythi...

haml with rails3 (git master) and devise: form_for syntax change breaks haml -- suggestions?

i am trying to get haml working with a rails3 project; since i am quite far in the modeling i wanted to go to the haml views now -- seems that the current haml (git master) does not work together with the current rails3 git master because of some syntax changes in rails3 form_for does anyone have more information on the syntax changes?...

searching for a guide how to setup mongo_mapper, devise, haml with rails3

is there a full setup guide for mongo_mapper, haml, rails3 and devise, for the current git (master) branches? a lot of things changed in all of those frameworks/libs lately. i was wondering if somebody has it up and running and can share it on github or give some pointers... ...

Observing activerecord for new records.

I want to implement a feature like in twitter where when new tweets show up the title changes. How to display the record when the record has just been created. ...

Jquery JCarousel, itemLastInCallback how to change out the controls

I am new to js and Jquery other than plug and play scripts and plugins. I have Jcarousel running great on a Ruby on Rails site and I need to use the itemLastInCallback method to change out the next and prev buttons. Basically if the end user clicks through to the last item in a carousel, the next button would become a link to the next ...

Include FileUtils raises an error

I am trying to install CruiseControl.rb on an Amazon EC2 instance. I get this error in the mongrel log: /data/cruisecontrol/releases/20100313003145/vendor/rails/activesupport/lib/active_support/dependencies.rb:105:in `const_missing': uninitialized constant ProjectsMigration::FileUtils (NameError) This error is raised in a file called p...

Redirecting from an update action to the referrer of the edit

My Rails 2.3 application has a User model and the usual controller actions. The edit form can be reached two ways: when a user edits his own profile from the home page, or when an admin user edits someone else's profile from users collection. What I'd like to do is have the update action redirect back to the referred of the edit action,...