ruby-on-rails

What is the recommended way for calling remote JSON objects from native blackberry apps?

Dear all, IF I am to develop a native application on blackberry, what would be the recommended way to call remote JSON object? As I understand native blackberry apps is coded using Java, would it still be able to contact a remote JSON object from Ruby on Rails? Has there been any blackberry framework to ease this use case? Thank you ve...

need an empty string, but getting an exception in ruby on rails

controller @articles = current_user.articles view <% @articles.each do |article| %> <%= link_to "#{article.title} , #{article.author.name}" articles_path%> <% end %> Sometimes the article has no author, so is null in the database, which results in the following error You have a nil object when you didn't expect it! The error occ...

RoR: How to prevent Url change after erronous edit?

In a standard generated scaffold project, when you are on an edit page, the URL looks like; /something/3/edit However, when the page doesn't validate, it runs the following code: format.html { :action => "edit" } and the page url changes to; /something/3 (no /edit) Why is this is this and how to prevent it, as it l...

How do I pass object values with render :action => 'new'

Hi, In an app I have the following: def new @property = Property.new(:country_id => 1, :user_id => current_user.id, :status_id => 'draft') end def create @property = Property.new(params[:property]) if @property.save flash[:success] = t('The_property_is_successfully_created') redirect_to myimmonatie_u...

formtastic - :string field value as Array and not found-s

Hi, is there any possibility to send from formtastic form value of :string field like - semantic_form_for :project do |form| - form.inputs do = form.input :task_ids, :as => :string as Array? Currently value of this field is sending as String and i'd like to no parse this string in controller. Also, could you give me idea - if task...

views count calculation

Hi, could you give me idea how to calculate unique views of page? If i will increase counter on each page load it will be no good, otherside storing information of viewed pages in session looks like not ideal solution. ...

ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken) in IE

Hello All, I am facing ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken) error when I am using IE for form submit but it works fine wih FF and Chrome. Please help me . Thanks MJ ...

Prevent a Rails model from saving

I have a scenario where I have a model that I want to populate and validate against, but don't necessarily want to write down to the database when it's parent object is. For instance, let's say I have an account and a credit card model, the credit card is built against the account, and validated when the account is, but also saved when ...

rails + compass: advantages vs using haml + blueprint directly

I've got some experience using haml (+sass) on rails projects. I recently started using them with blueprintcss - the only thing I did was transform blueprint.css into a sass file, and started coding from there. I even have a rails generator that includes all this by default. It seems that Compass does what I do, and other things. I'm tr...

Will these optimizations to my Ruby implementation of diff improve performance in a Rails app?

<tl;dr> In source version control diff patch generation, would it be worth it to use the optimizations listed at the very bottom of this writing (see <optimizations>) in my Ruby implementation of diff for making diff patches? </tl;dr> <introduction> I am programming something I have never done before and there might already be tools out...

Not able to upload in a passenger app behing apache

Am not able to upload a 8.4 MB file, in a passenger app behind apache. Transferring the same file via scp took 4.1 minutes. Error backtrace: [ pid=10222 file=ext/apache2/Hooks.cpp:727 time=2010-05-18 07:13:14.842 ]: Unexpected error in mod_passenger: An error occurred while receiving HTTP upload data: Connection reset by peer (104) B...

How to Resolve MySQL Error? Chaining Named Scopes

I'm trying to chain two named_scopes in my User model. The first: named_scope :commentors, lambda { |*args| { :select => 'users.*, count(*) as total_comments', :joins => :comments, :conditions => { :comments => { :public_comment => 1, :aasm_state => 'posted', :talkboard_user_id => nil} }, :group => 'user...

rails model using class hierarchy from an external gem ?

Hello, I'm working on a project where the data model is : implemented in a separate gem does not use ActiveRecord, nor any relational database storage ( actually it relies on couchdb ) makes usage of namespaces makes intensive usage of class inheritance To simplify the schema, let's say we have the following root class : module ...

ActiveRecord: issue with 'find' method when querying dates.

I'm struggling with the conditions for date querying in the 'find' method on my ActiveRecord models running over an SQLite3 database. My model is as follows: Day: failure_day: date failure_count: integer When I attempt to query Days, I get the following (pseudo code only): Query: Days.all Result: [{failure_day: 2010-04-14,...

Problems installing rdoc, irb, bluecloth, chronic on fedora 12

Hello, What do these errors mean? [root@localhost config]# gem install bluecloth Building native extensions. This could take a while... ERROR: Error installing bluecloth: ERROR: Failed to build gem native extension. /usr/bin/ruby extconf.rb can't find header files for ruby. Gem files will remain installed in /usr/lib64/ruby/g...

Sass mixin not compiling?

I have previously made a mixin in sass 2.2.22 for my font sizes(it's a font converter), like so: =6.5pts :font :size 9px It has been working ever since i first made it a year ago. We just upgraded to haml/sass 3 and now whenever I try to refresh the page im working on, a sass compile error appears like so: http://grab.by/4yFE ...

Using RJS to replace innerHTML with a real live instance variable.

I can't for the life of me get RJS to replace an element's innerHTML with an instance variable's attribute, i.e. something like @thing.name I'll show all the code (simplified from the actual project, but still complete), and I hope the solution will be forehead-slap obvious to someone... In RoR, I've made a simple page displaying a ran...

Rails/ActiveRecord Sub collection

I have three models: Store, Author, Books Store has many Authors which has many Books. What is the cleanest way to get a collection of all the books at the store? This works: @store.authors.collect{|a| a.books}.flatten Is there something in Active Record that I'm missing that makes this cleaner? Jake ...

Rails Routing with Namespace and format (for api)

I know this isn't RESTful, but for now, I'm trying to set up an api/v1 controller. Ideally I would like to call it like this: site.com/api/v1/verify.xml But right now I can't get the .xml to work. I have the following route so far: map.namespace :api do |api| api.connect ':controller/:action/:id' end I can do /api/v1/verify but...

How to hunt down a long running request in Rails

We have a customer complaining about a long running request. I found the request in the production.log but am not sure how to dig deeper into figuring out why it took so long. Is there any artifacts in the log that I should look for? Also the DB and View times don't add up to the total request time. ...