Category "ruby-on-rails"

Encoding 4 byte UTF-8 character to JSON from Rails produce invalid character

I have a web service in rails (3.2.19) that encode a JSON to be read by some iOS or Android apps. The json might contain any characters, but it seems to fail ev

How can i create JSON array of JSON objects in ruby from a loop

I am trying to loop through some video objects and i am trying to build a JSON array that looks like this: [{"event_name":"video_completed","object_id":1234567

Rspec 3 how to test flash messages

I want to test controller's action and flash messages presence with rspec. action: def create user = Users::User.find_by_email(params[:email]) if user

To show your comment first if you are logged (and if you left a comment)

I am editing a Book-page improving the Comments-Area. Now it is a "classic" area where the latest 3 comments are showed. But I want to edit it showing first the

How do I drop a foreign key if it exists in Ruby on Rails?

There's a function called index_exists? in ActionRecord, but no foreign_key_exists? on Rails 4.2.7. So when I call remove_foreign_key :parties, :franchise_gr

Terminal window in eclipse is blank. Ruby on Rails

When you install and configure RoR on windows and eclipse(Aptana plugin) you would see the terminal window in the eclipse perspective where you would type in va

Rails flash :error, :notice are lost on redirect but alert is not

The docs for redirect_to state clearly that redirect_to can take :alert => "x" and :notice=>"x" options for flash after the path, but anything else needs

Stripe - add an invalid card to customer in test mode?

I would like to test invoice.payment_failed event with VCR Pseudocode: create a customer with invalid card create an invoice with invoice item (here the invoice

Errno::ENOENT: No such file or directory @ rb_sysopen - /tmp/

I'm trying to push my app to Heroku, however I'm getting this rather arbitrary error: Errno::ENOENT: No such file or directory @ rb_sysopen -\ /tmp/buil

rdkafka 0.8.1 ERROR: Failed to build gem native extension

I'm runnning bundle install Then I get this error: Fetching rdkafka 0.8.1 Installing rdkafka 0.8.1 with native extensions Gem::Ext::BuildError: ERROR: Failed to

submitting a field with just enter button

How do I submit a form (it may be just one field, i will give example in a second) with just 'enter' button, without showing a submit button to the user, or eve

submitting a field with just enter button

How do I submit a form (it may be just one field, i will give example in a second) with just 'enter' button, without showing a submit button to the user, or eve

Ruby on Rails Slim Templates with HTML Entity Escaping

I have a RoR slim template with the following: input(type="text" placeholder="I'm looking for…") But sadly it outputs the HTML entity escape 'as-i

Rails CSS, JS, and jQuery TypeErrors (for Windows) [duplicate]

It has recently come to light that my program is experiencing plenty of errors on the localhost:3000 server. I'm quite new to Ruiby on Rails a

rack-attack configure text on blacklist page

Im using rack-attack to block an ip. # Block requests from 1.2.3.4 Rack::Attack.blocklist('block 1.2.3.4') do |req| # Requests are blocked if the return value

$(document).ready does not work in Rails

I'm using a *.js.erb in my Rails-App, which reacts to a clicked Link. But when I render my page, by getting there via a link_to, I have to refresh the Page, to

Rails public folder items not available in production

I have a few items that are accessible just fine in development mode within the /public directory of my app: favicon.ico, robots.txt. I can view these in devel

Ruby -- trying to grab <title>this here</title> even if on multiple lines

Currently, I am grabbing titles using the following method: title = html_response[/<title[^>]*>(.*?)<\/title>/,1] This does a great job at catch

full width responsive image with image tag in Rails 4 app

Im using the code below to make header images appear randomly in a app I´m making. I want the images to span the whole width of the screen but somehow it

Rails recursive association with migrations

I have a table named Nodes. Each node belongs to one father of the same table, and has one child on the same table too. This is the Node model: class Node <