stackoverflow.com Archives - 29 April 2017, Saturday

  • 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 ...

  • on Rails: Adding jQueryUI and Bootstrap icons on production environment

    stackoverflow.com 13 Jan '17, 12pm

    and restart apache. Bootstrap and jQueryUI works fine but i can't add icons (or glyphicons from Bootstrap). When i change environment to development icons works fine. The problem is only on production environment. I have tried add png files with icons and fonts files with glyphicons t...

  • twitter bootstrap - how do I use a bootstrapious theme on Ruby on Rails

    stackoverflow.com 12 Jan '17, 9pm

    I tried looking through already asked questions like basic bootstrap Integrate bootstrap theme in Ruby on Rails and How to integrate a Wrap Bootstrap theme into an Rails application? but when I try just adding the folders from the free downloaded bootstrapious theme, I get the basic o...

  • css - How to show an image in bootstrap based navbar on ruby on rails

    stackoverflow.com 12 Jan '17, 11am

    I want to place an image on the left in my Bootstrap based navbar in ruby on rails. My image does not show up. I suppose I did not reference the link well. How can I fix this? The image is in app/assets/images/logo.png <nav class="navbar navbar-default navbar-fixed-top" role="navigati...

  • on rails - Eager-load for custom joins in ActiveRecord

    stackoverflow.com 08 Jan '17, 12pm

    I have a table of restaurants that have many reservations. Now I would like to query all restaurants and in case they have reservations for 2 people it should preload these associations. In case there are no reservations for 2 it should still return the restaurants, but with an empty ...

  • twitter bootstrap - Ruby / Rails (5.0.0.1) - Material Design Lite: Creating form_for using MDL

    stackoverflow.com 21 Dec '16, 4pm

    I am attempting to create a Rails "form_for" using Material Design Lite for styling. I am following the Ruby on Rails Tutorial (Rails 5) by Micheal Hartl . Specifically, Chapter 7, Listing 7.15 "A form to sign up new users". This tutorial uses Twitter's Bootstrap. Since I am using MDL...

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

    stackoverflow.com 11 Dec '16, 8am

    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 =...

  • on rails - gem install nokogiri -v '1.6.8.1' fails

    stackoverflow.com 11 Dec '16, 3am

    gem install nokogiri -v '1.6.8.1' Building native extensions. This could take a while... ERROR: Error installing nokogiri: ERROR: Failed to build gem native extension. current directory: ~/.gem/ruby/2.3.1/gems/nokogiri-1.6.8.1/ext/nokogiri ~/.rubies/ruby-2.3.1/bin/ruby -r ./siteconf20...

  • ajax - Dynamic select tag in Ruby on Rails

    stackoverflow.com 13 Nov '16, 2pm

    I am a newbie to Ruby on Rails . I have started working in RoR month ago. My question is: How can I make dynamic select tag that shows me sizes based on selected color of the product variant via AJAX? Each product has many variants. Each variant has one color, one size and quantity. H...

  • Rails Best Practices - Ruby on Rails

    stackoverflow.com 13 Nov '16, 2pm

    "Fat Model, Skinny Controller" is a very good first step, but it doesn't scale well once your codebase starts to grow. Let's think on the Single Responsibility of models. What is the single responsibility of models? Is it to hold business logic? Is it to hold non-response-related logi...

  • Why is Ruby more suitable for Rails than Python?

    stackoverflow.com 03 Nov '16, 11am

    There are probably two major differences: Ruby has elegant, anonymous closures. Rails uses them to good effect. Here's an example: class WeblogController < ActionController::Base def index @posts = Post.find :all respond_to do |format| format.html format.xml { render :xml => @posts.to...

  • Rails - Could not find a JavaScript runtime?

    stackoverflow.com 28 Oct '16, 4pm

    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 ...