stackoverflow.com Archives - 22 August 2017, Tuesday

  • Rails - Could not find a JavaScript runtime?

    stackoverflow.com 10 Aug '17, 5am

    Note from Michael 12/28/2011 - I have changed my accept from this (rubytheracer) to above (nodejs) as therubyracer has code size issues. Heroku now strongly discourage it . It will 'work' but may have size/performance issues. If you add a runtime, such as therubyracer to your Gemfile ...

  • amazon web services - Continue A program even there is an error in

    stackoverflow.com 20 Jul '17, 9pm

    So I wrote a script that will update a policy version for all aws accounts that require it,all the accounts that require a update of policy are in a array and I looping through the array and updating the policy successfully, however, some of the accounts that need updating I do not ha...

  • on rails 3.1 - ExecJS and could not find a JavaScript runtime

    stackoverflow.com 14 Jul '17, 3pm

    I had a similar problem: my Rails 3.1 app worked fine on Windows but got the same error as the OP when running on Linux. The fix that worked for me on both platforms was to add the following to my Gemfile : gem 'therubyracer', :platforms => :ruby The trick is knowing that :platforms =...

  • Can't update avatar img without page refresh (rails, jquery)

    Can't update avatar img without page refresh (rails, jquery)

    stackoverflow.com 11 Jul '17, 5pm

    Apologies in advance. I'm new to using async calls and I've been struggling with this for a while now. I'd like to update a user avatar image without having to refresh the page after the image has been saved to the user model. <form class="edit_user" id="edit_user_<%= current_user.id ...

  • How do you get the Ruby on Rails generated id of a form element for reference in JavaScript?

    stackoverflow.com 03 Jul '17, 12pm

    @duskwuff I think you're making comments without understanding that both examples are two special cases of the same general case. The author gives just ONE example of “Ruby on Rails generated id of a form element” and I'm giving another example. Example A and Example B. But the questi...

  • javascript - Rails - execute an ajax call via select dropdown menu

    stackoverflow.com 22 Jun '17, 7am

    I have a view that contains a select tag, it is not part of a form just a stand alone drop down menu. On clicking one of the options I want to execute an ajax call This is the select tag <%= select_tag 'application_stage', options_for_select(application.job.hiring_procedure.hiring_pro...

  • javascript - Why escape_javascript before rendering a partial?

    stackoverflow.com 18 Jun '17, 9pm

    If you look at the source here , it will be much clearer. This function accomplishes the following two things: It substitutes the characters in the input string with the ones defined in JS_ESCAPE_MAP The purpose of this is to make sure that the javascript code is serialized correctly ...

  • on rails - How do I serialize an array field into MySQL?

    stackoverflow.com 29 May '17, 10am

    I have request_type as a array field in my database. For this I did following migration def change change_column :users, :request_type, :string, array: true, default: '{}' end which I got from this question . I also added serialize into the model file. class User < ActiveRecord::Base ...

  • on Rails - No route matches [POST] "/setor/update"

    stackoverflow.com 14 May '17, 12am

    i'm new to ruby on rails and I keep getting this error when trying to update an object. here's my controller: class SetorController < ApplicationController def index @setor = Setor.all end def new end def show @setor = Setor.find(params[:id]) end def create @setor = Setor.new(setor_pa...

  • In mongodb,How to use ruby on rails "migration" tools

    stackoverflow.com 03 May '17, 7pm

    In ruby on rails normally use SQLite as a database.so a special property of rails called migration are work.but when we use "mongodb" as a database in rails.I see there have no migrate folder in the db directory. Is there any way to use this migration property in rails when use mongodb.

  • AWS Elastic beanstalk Ruby App not loading Production ENV

    stackoverflow.com 01 May '17, 4pm

    My Ruby on Rails app on AWS Elastic beanstalk is for loading the staging environment, even though it has been configured as production. BUNDLE_PATH: vendor/bundle RAILS_ENV: production RAILS_SKIP_ASSET_COMPILATION: false RAILS_SKIP_MIGRATIONS: false BUNDLE_WITHOUT: test:development RA...

  • java - Learning Web Development : Django vs Node vs Rails vs Others

    stackoverflow.com 27 Apr '17, 7pm

    The asynchronous programming approach in Node.js is conceptually more difficult. While you can take a similar approach in Django or Rails, it's not common to do so. Node.js is really, really fast out of the box. But part of the reason for that is that it doesn't include very much OOB....

  • Writing beautiful Ruby

    idiom for "foo.nil? ? nil : foo.to_i"?

    stackoverflow.com 23 Apr '17, 2am

    def bar(foo) foo.to_i unless foo.nil? end But you don't really gain anything, IMO, except eliminating the ? ? . It's a character shorter, potentially more readable if you know Ruby. Don't know as it qualifies as "more concise" than the ternary. (I say "potentially" because it might be...

  • Common Ruby Idioms

    stackoverflow.com 22 Apr '17, 12am

    The magic if clause that lets the same file serve as a library or a script: if __FILE__ == $0 # this library may be run as a standalone script end Packing and unpacking arrays: # put the first two words in a and b and the rest in arr a,b,*arr = *%w{a dog was following me, but then he ...

  • on Rails - Emoji not saved in MySQL

    stackoverflow.com 31 Mar '17, 6pm

    I'm working on a Rails app where users can upload photos to their profiles. Every photo has a title, which is supposed to support emoji. Despite changing encoding of the table to utf8mb4 and modifying database.yml when i try to save a photo with emoji in its title MySQL returns an err...

  • on rails - Order query by number of times one model has another

    stackoverflow.com 25 Mar '17, 6am

    I have the following structure: User model: id, .. Event model: id, .. UserMapEvent model: user_id, event_id For example the UserMapEvent table might have the following records: User_id - Event_id 1 - 1 1 - 2 3 - 1 4 - 1 I'm using this structure to save when a user likes an event. Now...

  • How to remove bootstrap-sass from Ruby on Rails 5.0.2

    stackoverflow.com 24 Mar '17, 4am

    I'd like to remove bootstrap-sass 3.3.7 from ruby on rails. I installed gem bootstrap-sass a month ago. However, I created design by myself. So I would like to uninstall bootstrap-sass. I tried gem uninstall gem bootstrap-sass rake assets:clean but, bootstrap was not removed.

  • My ruby on rails product index page not displayed correctly

    stackoverflow.com 10 Mar '17, 6pm

    772 A concise explanation of nil v. empty v. blank in Ruby on Rails 10 Changing Index Page - Ruby on Rails 0 How to override a file that is causing trouble in Ruby on Rails Spree Commerce App? 0 Ruby on Rails: Counting how many times an images appears on screen 0 navbar in ruby on rai...

  • How to insert post data in mongodb using ruby on rails

    stackoverflow.com 06 Mar '17, 10am

    I am trying to insert article post data in mongodb collection but I got below error. Mongoid::Errors::NoParent at /articles message: Cannot persist embedded document Article without a parent document. summary: If the document is embedded, in order to be persisted it must always have a...

  • ¿?—Ruby on rails, Kaminari, paginate multiple Bootstrap tabs using Ajax https://t.co/hshdV5KDaP

    on rails, Kaminari, paginate multiple Bootstrap tabs using Ajax

    stackoverflow.com 02 Mar '17, 10am

    I work on app using Ruby on Rails, Mongoid, Bootstrap and Kaminari. I have a School page (with a model and controller) with many ratings on it. Ratings are separated in 3 parts : verified ratings, unverified ratings and all ratings. They are separated with a Bootstrap tabs. I want to ...

  • javascript - Ruby on rails live update

    stackoverflow.com 28 Feb '17, 4pm

    Okay, what i am looking for is a way to get an ajax script to run in the background of a page and look to see if there is a new record in the database and if there has grab that record and display that on my page. i also do not want to use plugins i would rather do this myself as i pr...

  • css - Ruby on Rails - Bootstrap - Columns not stacking Horizontally

    stackoverflow.com 16 Feb '17, 4pm

    A newbie at web designing here. I've been experiencing some problems trying to create columns for Rails using bootstrap. I installed bootstrap with this tutorial . This is what I have so far: <html> <body> <div id="main-container" class="container"> <div class="row"> <div id="A_Name_T...

  • Block discount on certain product shopify script

    stackoverflow.com 15 Feb '17, 4pm

    I want to write a script in Shopify that prevents discounts from rendering on certain products. I know this is wrong, but something like this: Input.cart.line_items.each do |line_item| product = line_item.variant.product if product = 123456789 CartDiscount.remove("Discount does not ap...

  • No automatic line break when exceeding textarea in form input field

    html - No automatic line break when exceeding textarea in form input field

    stackoverflow.com 13 Feb '17, 3am

    I have a form with an input field for a string. I resized the 'textarea' height to fit with the style I'm trying to achieve but I found two unexpected problems which I haven't been able to fix. The text input and placeholder values are centred vertically in the textarea. I'd like them...

  • javascript - Using an external React component on Rails application

    stackoverflow.com 01 Feb '17, 6pm

    I am trying to use the rc-slider React component on a existing Rails application that is using react-rails gem and it already have some other components that were built within the application that work just fine. Based on this blog post I've been able to follow its first 3 steps, I've...

  • ¿?—Import Twitter Bootstrap Template to Ruby on Rails Application https://t.co/yGQyJkBqnp

    css - Import Twitter Bootstrap Template to Ruby on Rails Application

    stackoverflow.com 25 Jan '17, 4pm

    I'm currently involved in a complex project which I will require help from this forum in order to complete! I am a novice; and have thus far only completed Michael Hartls Tutorial. Currently I am attempting to import this template into my new application. I have successfully got Boots...

  • javascript - Ruby on Rails - Sort by asc using jQuery

    stackoverflow.com 24 Jan '17, 10am

    var table = document.getElementById("targetTable"); var data = []; var sortAsc = true; for (var i = 0; i < 5; i++) { var obj = { id: i + 0, rowNode: document.createElement("tr"), idNode: document.createElement("td"), valueNode: document.createElement("td"), value: Math.random() * 1000...

  • on Rails - Default ascending sort bootstrap table for the filtered column

    stackoverflow.com 23 Jan '17, 2pm

    I'm a newbie in Rails, I want sort data in some code and I stuck... I have a problem with the default sorting (ASC) on my bootstrap table. I want to sort data by the 'Expires' column, but I'm not sure how in case of filters add attributes which will refer to only one column. Data-fiel...

  • AWS Gem Build Error when deploying Ruby on Rails App

    stackoverflow.com 20 Jan '17, 9am

    Hi I'm trying to switch to AWS and Elastic Beanstalk. I was able to get a successful sample instance of AWS going. I am trying to deploy my RoR app and am experiencing the following. An error occurred while installing nokogiri (1.6.6.2), and Bundler cannot continue. Make sure that `ge...

  • on Rails, create a record from another model

    stackoverflow.com 16 Jan '17, 3am

    Your first approach should be ok, you can save the Result from the File model. You do not need to use the instance variable @, as it is thought to send the variable to the view, and I can not imagine why you need so here. To sum up, in filedb.rb: # here you calculations and then cell ...