Monday, September 26, 2016

How could I use a regex expression in Ruby to ignore html tags? | Fixed issues

How could I use a regex expression in Ruby to ignore html tags? | Fixed issues


How could I use a regex expression in Ruby to ignore html tags?

Posted: 26 Sep 2016 08:02 AM PDT

I have a Blog ActiveRecord model in a rails application. The body property is text. It includes html tags for images, headings etc.. I want to create a method that takes the first n amount of text of the body to show on the index page as preview text. The problem is my method also grabbed all of the html tags so my method returns a string that looks like this.

Here is a picture I am talking about. <img src="path/to/image.png" / > <h1> Nice </h1>  

Is there regex solution to ignore all the tags?

can't make rails assets pipeline to works?

Posted: 26 Sep 2016 07:55 AM PDT

i am developing an app in rails with some css and js plugins template, by default we should separate or js and css file into javascript and css folder right?

but the problem is my plugins folder structure are quite complex, have a lot of sub folders, so i decided to put all the assets (css, js, images, fonts) into a folder, the problem is everything not working on production mode, the css styles, scripts, images all not loaded, please help.

here is my structure :

javascripts  stylesheets  public_assets    - img      - icon      - bg      - favicon      - images        - proteam      - png        - ualanding      - portofolio        - fullsize        - thumbnail    - font    - css    - js    - sass    - vendor      - ninja-slider      - bootstrap        - font        - css        - js      - font awesome         - css        - fonts        - less        - scss      - jquery      - magnific-popup      - scroolreveal    - vid  images  Static_Dev  

FYI i already run

rake assets:precompile

command

i reference my images mostly like these :

<img alt="UrbanAce" src="assets/img/logo.png" height="24">

i believe when i run on production mode, the assets path changed, so i changed my image tag to :

<%= image_tag "logo.png", { src: "logo.png", height: "24"} %>

the above code did not work, even in development mode.

also, what if i need to call some background images from css? something like :

 .hero {    background-image: url("../img/png/UA-Landing/UA-Pattern.png");    background-repeat: repeat-x;    background-position: 0 76px;    height: 280px;  }  

i call font like this :

@font-face{font-family:FreightSansPro;src:url(../font/FreightSansPro-Light.otf) format("opentype");  

how should i replace it? so it will work on production and development mode.

many thanks....

ruby-on-rails override state_machine in the inherited class

Posted: 26 Sep 2016 07:42 AM PDT

I have two ActiveRecord classes:

class Gateway::Transaction < ActiveRecord::Base    state_machine :initial => :setup do     # ... many events..    end  end  

and an inherited class

class Gateway::BetterTransaction < Gateway::Transaction    state_machine :initial => :setup do      # ... many events ...    end  end  

The problem is that all the events and rules from the base class are still in the inherited class.

I looked in the state_machine gem documentation and saw no option of how to modify this behavior - only that if a transition exists (also in the base class) then the state machine will use the first found transition.

Is there a way to override the state machine from the base class with a new one?

How to check if a string contain valid hash

Posted: 26 Sep 2016 08:00 AM PDT

i encounter a problem when i want to validate the input string if it contain a valid hash before execute eval on it, for example:

"{:key=>true}" if i run eval it return a correct hash, but if i run eval on this string "{:key=>true" i get syntax error of expected token:

(eval):1: syntax error, unexpected end-of-input, expecting '}' {:redirect=>true ^  

i did tried some basic validation but no luck so far.

so basically what i want to know is how to validate a that a string contain correct hash format.

Import images from xls sheet in Rails

Posted: 26 Sep 2016 07:30 AM PDT

Can anybody help me in importing images from xls in ruby application. I tried 'roo', 'spreadsheet' gem to parse xls sheet, but none of them get the image from the sheet, getting nil everytime.

I just want to insert an image in a cell and get that image in ruby.

Can anybody help me out of this?

Ruby on Rails Tutorial by Michael Hartl Chapter 8 failing last test under 8.31 listing

Posted: 26 Sep 2016 07:26 AM PDT

When trying to make a test in https://www.railstutorial.org/book/basic_login#code-user_logout_test using 8.31 listing:

 require 'test_helper'    class UsersLoginTest < ActionDispatch::IntegrationTest    .    .    .    test "login with valid information followed by logout" do      get login_path      post login_path, params: { session: { email:    @user.email,                                            password: 'password' } }      assert is_logged_in?      assert_redirected_to @user      follow_redirect!      assert_template 'users/show'      assert_select "a[href=?]", login_path, count: 0      assert_select "a[href=?]", logout_path      assert_select "a[href=?]", user_path(@user)      delete logout_path      assert_not is_logged_in?      assert_redirected_to root_url      follow_redirect!      assert_select "a[href=?]", login_path      assert_select "a[href=?]", logout_path,      count: 0      assert_select "a[href=?]", user_path(@user), count: 0    end  end  

I am getting a failure:

FAIL["test_login_with_valid_information_followed_by_logout", UsersLoginTest, 1.7831762819550931]   test_login_with_valid_information_followed_by_logout#UsersLoginTest (1.78s)          Expected at least 1 element matching "a[href="/login"]", found 0..          Expected 0 to be >= 1.          test/integration/users_login_test.rb:35:in `block in <class:UsersLoginTest>'  

Maybe someone know where is a problem? I double check the chapter, seems that everything is done as in tutorial said.

Much obliged,

Heroku run rake db:migrate Errno::EISDIR: Is a directory @ io_fillbuf - fd:9 /app/.fog

Posted: 26 Sep 2016 07:43 AM PDT

Hi all so after pushing my code to Heroku, i am currently unable to run heroku run rake db:migrate and this is the error i am getting.

rake aborted Errno::EISDIR: Is a directory @ io_fillbuf - fd:9 /app/.fog

To provide some context, i am using fog-google to support media uploads in production.

In config/initializers/fog.rb the code is as follows

GoogleStorage = Fog::Storage::Google.new(    :google_project => 'XXXX',    :google_client_email => 'XXXXX',    :google_json_key_location => Rails.root.join('.fog/XXXX'),    :google_storage_access_key_id => ENV['GOOGLE_STORAGE_ACCESS_KEY_ID'],    :google_storage_secret_access_key => ENV['GOOGLE_STORAGE_SECRET_ACCESS_KEY']  )  

My google_json_key_location is saved in a .fog folder. I'm not sure if that's what is causing the error because heroku can't find the file since the .fog folder is not uploaded onto my Git Repo. But i'm not quite sure where else should i be saving my JSON Private Key file as i think it shouldn't be something uploaded onto my git repo?

EDIT: I amended the folder from .fog to just fog so now i am able to run heroku run rake db:migrate

The problem is that i'm quite sure i shouldn't be saving this file onto my git. What is an alternative solution for saving this file privately and still being able to access it on heroku?

All help and advice would be greatly appreciated! Thank you so much!

get details of user through github api gem in rails

Posted: 26 Sep 2016 07:40 AM PDT

i am using the "github_api" gem in my project to get user data through github

and hear is my controller got this task

class SocialController < ApplicationController    def index    end      def authorize      address = github.authorize_url redirect_uri: 'http://localhost:3000/social/callback'      redirect_to address    end      def callback      puts params      authorization_code = params[:code]      access_token = github.get_token authorization_code      access_token.token         puts Github::Client::Repos.new.list    end      private      def github      @github ||= Github.new client_id: 'f11661f7a9ba943', client_secret: '08aa35ed997b162de257c'    end  end  

and i am calling it through this link in my views

<%=link_to "gitouath", controller: "social", action: "authorize" %>  

by this i am able to authorize the github profile but i need some other details like his name, profile and projects but i am not able to figure it out, please tell me if there is a way to get those details

Rails read value of a number_field and display it on page

Posted: 26 Sep 2016 06:28 AM PDT

My goal is to use coffeescript to read the value from a number_field in the view, send the value to the coontroller and then send the number value from the controller back to the view.

In the coffeescript file I use console.log(qty) as a check to see, if coffeescript is able to read the number_field value. This check passes.

In the controller I use puts "received #{@n}" and puts "not received" as checks. On page load the else portion should execute, since the .change event has not yet triggered. When the number field is changes the if portion should execute. This test passes correctly. When the number field is changed the correct value for @n is printed to the rails console. This means that the params[:quantity] is received by the controller action.

The last step would be for $('#insert-here').load(location.href+" #insert-here") to reload the #insert-here div on the page. To check this I added <%= Time.now %> in the view to see that the timestamp changes. This test passes as well, but <h1><%= @n %></h1> in the view continues to show the number 1. It does not update. How can I fix this?

View

<%= oi.number_field :quantity, value: 1, class: 'form-control', id: 'quantity-select', min: 1 %>  <div class="col-xs-12" id="insert-here"><h1><%= @n %></h1><h2><%= Time.now %></h2></div>  

Coffeescript

ready = ->    $('input[type=number][id=quantity-select]').change ->      qty = document.getElementById('quantity-select').value      $.ajax        complete: (request) ->        data: { quantity: qty }        console.log(qty)        $('#insert-here').load(location.href+" #insert-here")      return    return  $(document).ready(ready)     

Controller

 def show     if params[:quantity].present?       @n = params[:quantity]       puts "received #{@n}"     else       @n = 1       puts "not received"     end    end  

Why am I getting sporadic disconnects when using capybara-webkit gem in Rails 4?

Posted: 26 Sep 2016 06:37 AM PDT

I use the capybara-webkit gem to scrape data from certain pages in my Rails application. I've noticed, what seems to be "random" / "sporadic", that the application will crash with the following error:

Capybara::Webkit::ConnectionError: /home/daveomcd/.rvm/gems/ruby-2.3.1/gems/capybara-webkit-1.11.1/bin/webkit_server failed to start.      from /home/daveomcd/.rvm/gems/ruby-2.3.1/gems/capybara-webkit-1.11.1/lib/capybara/webkit/server.rb:56:in `parse_port'      from /home/daveomcd/.rvm/gems/ruby-2.3.1/gems/capybara-webkit-1.11.1/lib/capybara/webkit/server.rb:42:in `discover_port'      from /home/daveomcd/.rvm/gems/ruby-2.3.1/gems/capybara-webkit-1.11.1/lib/capybara/webkit/server.rb:26:in `start'      from /home/daveomcd/.rvm/gems/ruby-2.3.1/gems/capybara-webkit-1.11.1/lib/capybara/webkit/connection.rb:67:in `start_server'      from /home/daveomcd/.rvm/gems/ruby-2.3.1/gems/capybara-webkit-1.11.1/lib/capybara/webkit/connection.rb:17:in `initialize'      from /home/daveomcd/.rvm/gems/ruby-2.3.1/gems/capybara-webkit-1.11.1/lib/capybara/webkit/driver.rb:16:in `new'      from /home/daveomcd/.rvm/gems/ruby-2.3.1/gems/capybara-webkit-1.11.1/lib/capybara/webkit/driver.rb:16:in `initialize'      from /home/daveomcd/.rvm/gems/ruby-2.3.1/gems/capybara-webkit-1.11.1/lib/capybara/webkit.rb:15:in `new'      from /home/daveomcd/.rvm/gems/ruby-2.3.1/gems/capybara-webkit-1.11.1/lib/capybara/webkit.rb:15:in `block in <top (required)>'      from /home/daveomcd/.rvm/gems/ruby-2.3.1/gems/capybara-2.7.1/lib/capybara/session.rb:85:in `driver'      from /home/daveomcd/.rvm/gems/ruby-2.3.1/gems/capybara-2.7.1/lib/capybara/session.rb:233:in `visit'  

It happens even after it's already connected and accessed a website multiple times before. Here's a code snippet of what I'm using currently...

if site.url.present?      begin      # Visit the URL      session = Capybara::Session.new(:webkit)      session.visit(site.url)  # here is where the error occurs...      document = Nokogiri::HTML.parse(session.body)        # Load configuration options for Development Group      roster_table_selector = site.development_group.table_selector      header_row_selector   = site.development_group.table_header_selector      row_selector   = site.development_group.table_row_selector      row_offset     = site.development_group.table_row_selector_offset      header_format_type    = site.config_header_format_type        # Get the Table and Header Row for processing      roster_table        = document.css(roster_table_selector)      header_row          = roster_table.css(header_row_selector)      header_hash         = retrieve_headers(header_row, header_format_type)        my_object = process_rows(roster_table, header_hash, site, row_selector, row_offset)      rescue ::Capybara::Webkit::ConnectionError => e      raise e      rescue OpenURI::HTTPError => e      if e.message == '404 Not Found'        raise "404 Page not found..."      else        raise e      end    end  end  

I've even thought perhaps I don't find out why it's happening necessarily - but just recover when it does. So I was going to do a "retry" in the rescue block for the error but it appears the server is just down - so I get the same result when retrying. Perhaps someone knows of a way I can check if the server is down and restart it then perform a retry? Thanks for the help!

/usr/bin/ruby: bad interpreter: No such file or directory

Posted: 26 Sep 2016 06:11 AM PDT

I am using capistrano for deployment of rails application. But while i am deploying my rails code into server i am getting following error.

The deploy has failed with an error: Exception while executing on host 00.00.00.00: bundle exit status: 126  bundle stdout: /home/rod/.rvm/scripts/set: /usr/local/bin/bundle: /usr/bin/ruby: bad interpreter: No such file or directory  /home/rod/.rvm/scripts/set: line 19: /usr/local/bin/bundle: Success  

How can i solve this issue?

Rails: how to display all pending friend requests?

Posted: 26 Sep 2016 06:47 AM PDT

I'm working on my first Rails project and I have a small problem. I'd really appreciate any help. I want to display all pending friend requests for a current user using each iterator. My controller:

class FriendRequestsController < ApplicationController  before_action :set_friend_request, except: [:index, :new, :create]    def index    @incoming = FriendRequest.where(friend: current_user)    @outgoing = current_user.friend_requests  end    def new    @friend_request = FriendRequest.new  end    def create    friend = User.find(params[:friend_id])    @friend_request = current_user.friend_requests.new(friend: friend)    if @friend_request.save      redirect_back(fallback_location: root_path), status: :created, location: @friend_request    else      render json: @friend_request.errors, status: :unprocessable_entity    end  end  

When I try something like a code below, it kinda works, the conditional statement works as it should, but I know it's a terrible way to make it work, so I'd like to use @incoming since it's defined.

<% if FriendRequest.where(friend: current_user).present? %>     <% ?.each do |request| %>         <li><%= ? %></li>     <% end %>  <% else %>      You don't have any friend requests  <% end %>  

But when I try something like:

<% if @incoming.present? %>  

The conditional statement doesn't work properly and there's 'You don't have any friend requests', even though the current user has a pending friend request. I don't exactly get how everything works in RoR yet, so I'd be thankful for an explanation.

How to apply association rules

Posted: 26 Sep 2016 07:41 AM PDT

I'm confusing about association. I tried to write code below but rails was returned me "undefined method `subs'".

def show    @product = Product.find(params[:id])    @materials = @product.materials.subs    respond_to do |format|      format.json { render json: [ @product,@materials ]}    end  end  

I want Product model relates to Sub model and I get Sub model record. If someone knows about this problem to solve please tell me.

class Product < ActiveRecord::Base    has_many :product_materials    has_many :materials, :through => :product_materials  end    class ProductMaterial < ActiveRecord::Base    belongs_to :product    belongs_to :material  end    class Material < ActiveRecord::Base    has_many :product_materials    has_many :products, :through => :product_materials    has_many :material_subs    has_many :subs, :through => :material_subs  end    class MaterialSub < ActiveRecord::Base    belongs_to :material    belongs_to :sub  end    class Sub < ActiveRecord::Base    has_many :material_subs    has_many :materials, :through => :material_subs  end  

Rails 5 Rspec receive with ActionController::Params

Posted: 26 Sep 2016 06:41 AM PDT

I have just upgraded to Rails 5. In my specs I have the following

expect(model).to receive(:update).with(foo: 'bar')

But, since params no longer extends Hash but is now ActionController::Parameters the specs are failing because with() is expecting a hash but it is actually ActionController::Parameters

Is there a better way of doing the same thing in Rspec such as a different method with_hash?

I can get around the issue using

expect(model).to receive(:update).with(hash_including(foo: 'bar'))

But that is just checking if the params includes that hash, not checking for an exact match.

undefined method `each' for nil:NilClass, how to set my instance variable?

Posted: 26 Sep 2016 05:48 AM PDT

I am trying to search by keywords some titles, I need help to set my instances variables tutos.... ( It seems that I need two instances @tutos... but I don't know how to do?

I tried: @tutos = Tuto.all.includes(:user, :category) || Tuto.search(params[:search]) but I have the same error... I have undefined method each' for nil:NilClass even though I have the instance variable set... thanks for your help

my controller

class TutosController < ApplicationController    before_action :authenticate_user!, only: [:new, :create]    before_action :set_tuto, only: [:show, :edit, :update, :destroy, :upvote]        def index      @tutos = Tuto.all.includes(:user, :category)      keyword_search      @categories = Category.all    end      def keyword_search      @tutos = Tuto.search(params[:search])    end      def show      @tuto = Tuto.find(params[:id])      @user = User.all    end      def new      @tuto = Tuto.new    end      def edit    end      def create        @tuto = Tuto.new(tuto_params)      @tuto.user_id = current_user.id        respond_to do |format|        if @tuto.save          flash[:success] = "Test"          format.html { redirect_to @tuto, notice: 'Tuto was successfully created.' }          format.json { render :show, status: :created, location: @tuto }        else          format.html { render :new }          format.json { render json: @tuto.errors, status: :unprocessable_entity }        end      end    end      def update      respond_to do |format|        if @tuto.update(tuto_params)          format.html { redirect_to @tuto, notice: 'Tuto was successfully updated.' }          format.json { render :show, status: :ok, location: @tuto }        else          format.html { render :edit }          format.json { render json: @tuto.errors, status: :unprocessable_entity }        end      end    end        def destroy      @tuto.destroy      respond_to do |format|        format.html { redirect_to tutos_url, notice: 'Tuto was successfully destroyed.' }        format.json { head :no_content }      end    end        def upvote      @tuto.upvote_by current_user      redirect_to :back    end        private          def set_tuto        @tuto = Tuto.find(params[:id])      end        def tuto_params        params.require(:tuto).permit(:title, :content, :id, :user_id, :category_id)      end  end  

my index

.container    .row      .col-xs-12        h1.text-gray Tutorials         h4 Search by Title        =form_tag tutos_path, :method => 'get' do           =text_field_tag :search, params[:search]          =submit_tag "Search", class:'btn btn-default'            = form_tag '/tutos', method: 'get' do            select[name="category.id"]              - @categories.each do |category|                |  <option value="                = category.id                | ">                = category.name            input[type="submit" value="Search", class="btn btn-default"]        .col-xs-12        -if user_signed_in?          = link_to "Create a tuto", new_tuto_path, class:"btn btn-success"        br        br          #tutos.transitions-enabled    -@tutos.each do |tuto|      .box.panel-default        = link_to image_tag(image_by_category(tuto.category.try(:name))), tuto_path(tuto)            h3 = link_to tuto.title, tuto_path(tuto), class:"title-link"             h6           | Created by:          span<>          = tuto.user.full_name        br        span.glyphicon.glyphicon-heart        span<>        = tuto.get_upvotes.size        br        br  

tuto model

class Tuto < ActiveRecord::Base    acts_as_votable    belongs_to :user    belongs_to :category    validates :category_id, presence: true        def self.search(search)      if search        where(["title LIKE ?","%#{search}%"])      else        all      end    end  end  

ReferenceError: 'PAPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGX' is undefined

Posted: 26 Sep 2016 05:25 AM PDT

We are getting lots of these errors (in thousands) on errbit.

ReferenceError: 'PAPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGX' is undefined

-------------------------------------------------------  | BROWSER   | 81.3% Mozilla 5.0 (Windows 8.1)         |  |           | 18.7% Mozilla 5.0 (Windows NT 10.0)     |  |-----------|-----------------------------------------|  | BACKTRACE | /Unknown script code:410:6→ Global code |  |-----------|-----------------------------------------|  | PARAMS    | {}                                      |  -------------------------------------------------------  

There is nothing in backtrace

I searched through SO but there are no answers for the question and found nothing

NOTE: Please do not close this question as its not answered on SO

Convinient way to implement user roles in my app

Posted: 26 Sep 2016 05:38 AM PDT

Thanks for reading!

I'm currently working on my new app and searching for the best way to implement next feature

By scenario I need to implement "As a user a have role in the location"

WHAT I HAVE DONE:

Scenario: When user adds new location to the profile one of the requred fields is "role". That could be "guest", "manager" or "seller". What's the best way to accomplish his in the model side?

I accomplished this with has_many_through assosiation

CONTROLLER:

def create      @location = Location.new(location_params)      @location.profiles << current_user.profile      #set user role      current_user.profile.profile_location_throughs.where(location_id: location.id).set_role(params[:location][:role])      respond_to do |format|        if @location.save          ....        end      end  end  

MODELS:

class Profile < ActiveRecord::Base do    has_many :profile_location_throughs    has_many :locations, through: :profile_location_throughs  end    class Location < ActiveRecord::Base do    has_many :profile_location_throughs    has_many :locations, through: :profile_location_throughs  end    class ProfileLocationThrough < ActiveRecord::Base    # with boolean fields: manager, seller, guest      belongs_to :location    belongs_to :profile      def set_role(role)      case role        when "guest"          self.guest = true        when "seller"          self.seller = true        when "manager"          self.manager = true      end    end    end  

=====

QUESTION: Could you suggest more beatiful way to implement his feature?

Unicorn stuck in loop: Refreshing Gem list

Posted: 26 Sep 2016 04:54 AM PDT

I'm using Rails 4.0.0, Ruby 2.3 and Unicorn.

My app was working perfectly until the day I tried to add a nem gem in my Gemfile. Everything's working like a charm locally, but when I deploy to DO using Capistrano, I get stuck in a loop with the error:

E, [2016-09-26T11:40:29.801388 #24545] ERROR -- : reaped #<Process::Status: pid 4280 exit 1> worker=0  I, [2016-09-26T11:40:29.802952 #4287]  INFO -- : Refreshing Gem list  /home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/activesupport-4.0.0/lib/active_support/values/time_zone.rb:282: warning: circular argument reference - now  E, [2016-09-26T11:40:32.116762 #4287] ERROR -- : uninitialized constant Vimeo::HTTParty (NameError)  /home/deployer/apps/my_app/releases/20160924171252/app/controllers/webinars_controller.rb:2:in `<class:Vimeo>'  /home/deployer/apps/my_app/releases/20160924171252/app/controllers/webinars_controller.rb:1:in `<top (required)>'  /home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/railties-4.0.0/lib/rails/engine.rb:465:in `block (2 levels) in eager_load!'  /home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/railties-4.0.0/lib/rails/engine.rb:464:in `each'  /home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/railties-4.0.0/lib/rails/engine.rb:464:in `block in eager_load!'  /home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/railties-4.0.0/lib/rails/engine.rb:462:in `each'  /home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/railties-4.0.0/lib/rails/engine.rb:462:in `eager_load!'  /home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/railties-4.0.0/lib/rails/engine.rb:347:in `eager_load!'  /home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/railties-4.0.0/lib/rails/application/finisher.rb:56:in `each'  /home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/railties-4.0.0/lib/rails/application/finisher.rb:56:in `block in <module:Finisher>'  /home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `instance_exec'  /home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `run'  /home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/railties-4.0.0/lib/rails/initializable.rb:55:in `block in run_initializers'  /home/deployer/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:228:in `block in tsort_each'  /home/deployer/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'  /home/deployer/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from'  /home/deployer/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:349:in `block in each_strongly_connected_component'  /home/deployer/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:347:in `each'  /home/deployer/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:347:in `call'  /home/deployer/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:347:in `each_strongly_connected_component'  /home/deployer/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each'  /home/deployer/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each'  /home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/railties-4.0.0/lib/rails/initializable.rb:54:in `run_initializers'  /home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/railties-4.0.0/lib/rails/application.rb:215:in `initialize!'  /home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:30:in `method_missing'  /home/deployer/apps/my_app/releases/20160924171252/config/environment.rb:5:in `<top (required)>'  config.ru:4:in `require'  config.ru:4:in `block in <main>'  /home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/rack-1.5.5/lib/rack/builder.rb:55:in `instance_eval'  /home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/rack-1.5.5/lib/rack/builder.rb:55:in `initialize'  config.ru:1:in `new'  config.ru:1:in `<main>'  /home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/unicorn-5.1.0/lib/unicorn.rb:56:in `eval'  /home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/unicorn-5.1.0/lib/unicorn.rb:56:in `block in builder'  /home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/unicorn-5.1.0/lib/unicorn/http_server.rb:752:in `build_app!'  /home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/unicorn-5.1.0/lib/unicorn/http_server.rb:617:in `init_worker_process'  /home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/unicorn-5.1.0/lib/unicorn/http_server.rb:639:in `worker_loop'  /home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/unicorn-5.1.0/lib/unicorn/http_server.rb:508:in `spawn_missing_workers'  /home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/unicorn-5.1.0/lib/unicorn/http_server.rb:519:in `maintain_worker_count'  /home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/unicorn-5.1.0/lib/unicorn/http_server.rb:283:in `join'  /home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/unicorn-5.1.0/bin/unicorn:126:in `<top (required)>'  /home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/bin/unicorn:23:in `load'  /home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/bin/unicorn:23:in `<top (required)>'  /home/deployer/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.1/lib/bundler/cli/exec.rb:74:in `load'  /home/deployer/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.1/lib/bundler/cli/exec.rb:74:in `kernel_load'  /home/deployer/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.1/lib/bundler/cli/exec.rb:27:in `run'  /home/deployer/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.1/lib/bundler/cli.rb:332:in `exec'  /home/deployer/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.1/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'  /home/deployer/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.1/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'  /home/deployer/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.1/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'  /home/deployer/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.1/lib/bundler/cli.rb:20:in `dispatch'  /home/deployer/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.1/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'  /home/deployer/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.1/lib/bundler/cli.rb:11:in `start'  /home/deployer/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.1/exe/bundle:34:in `block in <top (required)>'  /home/deployer/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.1/lib/bundler/friendly_errors.rb:100:in `with_friendly_errors'  /home/deployer/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.1/exe/bundle:26:in `<top (required)>'  /home/deployer/.rvm/gems/ruby-2.3.0/bin/bundle:23:in `load'  /home/deployer/.rvm/gems/ruby-2.3.0/bin/bundle:23:in `<main>'  /home/deployer/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'  /home/deployer/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'  

I don't know exactly what's happening, because I can use the code from this new Gem locally but when deployed it don't load, or don't install.

Seems that could be a syntax problem searching on Google, but don't know how to make sure because it was a long time ago I haven't added a Gem, so the syntax erro could be so old. Is there some tool to check if there's a syntax error? And I thing it's weird since it's working locally.

My Gemfile

source 'https://rubygems.org'    # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'  gem 'rails', '4.0.0'    # Use SCSS for stylesheets  gem 'sass-rails', '~> 4.0.0'    # Use Uglifier as compressor for JavaScript assets  gem 'uglifier'    # Use CoffeeScript for .js.coffee assets and views  gem 'coffee-rails', '~> 4.0.0'    # See https://github.com/sstephenson/execjs#readme for more supported runtimes  # gem 'therubyracer', platforms: :ruby    # Use jquery as the JavaScript library  gem 'jquery-rails'    # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks  gem 'turbolinks'  gem 'jquery-turbolinks'    # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder  gem 'jbuilder', '~> 1.2'    # gem 'anjlab-bootstrap-rails', :require => 'bootstrap-rails', :github => 'anjlab/bootstrap-rails'  gem 'bootstrap-sass', '~> 3.2.0'    gem 'devise'    gem 'paperclip', '~> 3.0'  gem 'aws-sdk', '~> 1'  gem 'nokogiri', '~> 1.5.1'    gem 'wicked_pdf'  # gem "wkhtmltopdf-heroku", :git => 'git://github.com/camdez/wkhtmltopdf-heroku.git'  gem "wkhtmltopdf-binary"  gem 'newrelic_rpm'  gem 'validates_email_format_of'  # gem 'will_paginate', '~> 3.0.6'  gem 'will_paginate-bootstrap'    gem 'iconv'  gem 'roo'  gem 'roo-xls'    gem 'airbrake', '~> 4.3'  gem "paranoia", "~> 2.0"  gem 'ransack'    gem 'omniauth-facebook'  gem 'omniauth-google-oauth2'  gem 'activerecord-session_store', github: 'rails/activerecord-session_store'  gem 'nested_form_fields'  gem 'httparty'      group :doc do    # bundle exec rake doc:rails generates the API under doc/api.    # gem 'sdoc', require: false  end    # Use ActiveModel has_secure_password  # gem 'bcrypt-ruby', '~> 3.0.0'    # Use unicorn as the app server    # Use Capistrano for deployment  group :development do    gem 'sqlite3'    gem 'awesome_print'      gem "capistrano", "~> 3.6"    gem 'capistrano-rails', '~> 1.1'    gem 'capistrano-rvm'    gem 'capistrano3-unicorn'      gem 'capistrano-local-precompile', require: false  end    group :production do    gem 'unicorn'    gem 'pg'    gem 'rails_12factor'  end    # Use debugger  # gem 'debugger', group: [:development, :test]  

Email - From address is the logged in address and not the address that specified in 'from' attribute

Posted: 26 Sep 2016 05:58 AM PDT

Below is the code for the mailer which sends the verification email:

ApplicationMailer

class ApplicationMailer < ActionMailer::Base    default from: "from@example.com"    layout 'mailer'  end  

SendVerificationMailer

class SendVerificationMailer < ApplicationMailer    def send_verification(verification_id)      @verification = Verification.find(verification_id)      @email = @verification.email      @token = @verification.token      mail :from => "Support <support@domain.io>", :to => @email, :subject => "User verification code"    end  end  

In production.rb I have configured the action_mailer as follows:

  # Mailing preferences    config.action_mailer.default_url_options = { :host => ENV["HOST_NAME"] }    config.action_mailer.delivery_method = :smtp    config.action_mailer.smtp_settings = {        :enable_starttls_auto => true,        :address => ENV["SMTP_ADDRESS"],        :port => ENV["SMTP_PORT"],        :domain => ENV["SMTP_DOMAIN"],        :authentication => :login,        :user_name => ENV["EMAIL"],        :password => ENV["PASSWORD"]    }  

I used an account info@domain.io for smtp user_name and password. When I send Email from local machine it is working fine and the from address in the received mail is support@domain.io in both development and production mode.

But, when the mail is sent from production machine in AWS the from address displayed as info@domain.io and not support@domain.io what I expect to be.


I am using AWS Elastic Beanstalk for deployment in which I have a web server and a worker, where the worker takes the attributes from SQS queue and send the Email.

Can anyone help me in fixing this. Thank you..

Save file name to the db after it's uploaded from the browser and refresh

Posted: 26 Sep 2016 07:20 AM PDT

I upload file from the browser to S3 (it works):

view

<form action="<%= @url %>" method="post" enctype="multipart/form-data">  Key to upload: <input type="input" name="key" value="<%= create_filename %> " /><br />  <!-- some other fields -->  File: <input type="file" name="file" /> <br />  <input type="submit" name="submit" value="Upload to Amazon S3" onclick="<%= validate_file_and_submit(@filename) %>" />  

controller

  def validate_file_and_submit(filename)      new_image = Image.new(        post_id: params['post_id'],        user_id: current_user.id,        filename: filename      )      if new_image.save        redirect_to post_path(params['id'])      end    end  

I need to save the new filename generated by create_filename to the db Image.filename and also refresh the page after successful upload or display an error if it failed.

edit: I'd appreciate if anyone could help or tell me why the question is idiotic instead of -1. Been told I must upload the file from the browser, cant use the backend but must store the name in the db.

ruby, enable chat between two users

Posted: 26 Sep 2016 04:57 AM PDT

I am on RoR and I would like to know if anyone can explain how I can create a system which displays a button for sending a message invitation to an other user.

If I havn't send invitation, then the button should be "Send invitation", else the button should be "Remove invitation".

I have created a messaging system that allows communication between all users of my website.I also have created an notification system which help them send notification to users.

I have a MVC application for my "send_invitation" system but not sure how to create a method which will send notification to other user. And also to ensure that when the user accepts the request, they should be allowed to exchange messages. I want a clarification on the above process.

Stop Rails Anchor param getting encoded

Posted: 26 Sep 2016 04:00 AM PDT

While using Kaminari gem in rails, I got to add an anchor value inorder to load the tabs correctly. But rails encoding the "#" symbol, which preventing the page from rendering correctly. Is there any chance to prevent this from happening.

sample code: <%= paginate products, params: {anchor: 'tab1'} %>

Thanks in advance.

Test runs on development instead of on TEST environment

Posted: 26 Sep 2016 03:33 AM PDT

Guard gem is installed. When I run test with bundle exec guard,and pry somewhere within a test scope, RAILS_ENV outputs development instead of test.

So I need to do something like RAILS_ENV=test bundle exec guard all the time.

Any ideas to fix this behaviour?

import salesforce database in my rails app

Posted: 26 Sep 2016 03:58 AM PDT

I created a Rails app with Heroku and i have to import data from Salesforce.

I followed guides from the Devcenter Heroku to setup the project but i have no idea about how to use my database in rails

heroku config command show my variable DATABASE_URL (I added it to my env).

here my database.yml. I set the same in development and production (I know it's bad)

defaul: &default  adapter: postgresql  encoding: unicode  pool: <%= ENV.fetch("RAILS_MAX_THREADS") {5} %>    production:  <<: *default  adapter: postgresql  database: <%= ENV['DATABASE_URL'] %>  username: postgres  password: <%= ENV['DATABASE_PASSWORD'] %>  host: localhost  

I can access to my database with psql but only with '$DATABASE_URL' in argument. I can't connect to it with '\c'

#psql $DATABASE_URL my_db=> \dt salesforce.*

And it display tables from salesforce I selected on Heroku connect. I can also add or remove content.

I want to do the same into my app: add or remove something from a HTML form, display content of this db...

I'm a beginner with Salesforce and Rails

EDIT for Caffein coder: My schema.rb. I may modify it by following some tutorials but i'm not sure at all

ActiveRecord::Schema.define(version: 20160923134925) do    enable_extension "plpgsql"    enable_extension "hstore"    create_table "products", force: :cascade do |t|      t.string  "title"      t.integer "price"      t.text    "description    end  end  

Error handling to return error object in services

Posted: 26 Sep 2016 04:09 AM PDT

This is CreateSubscription service class. I put this logic in service because there are api calls and some data insertion occurs. (This is simplified version.)

This class is called basically from controller, and I need to handle errors there. However the question is how can I triger errors with user.erros object instead of full_messages, so that I can iterate the errors and create error response with JSON.

{ "error": "Uuid can't be blank, Name can't be blank, and Email is invalid" }

to

{ "errors": [ { "uuid": [ "can't be blank" ],"name" : ["can't be blank"].. } ] }

services/create_subscription.rb

class CreateSubscription    class UserCreateError < StandardError; end      def self.call(plan, user_info:)      subscription = nil      ActiveRecord::Base.transaction do        user = CreateUser.call(user_info)        raise UserCreateError.new(user.errors.full_messages.to_sentence) unless user.valid?  

service/create_user.rb

class CreateUser    def self.call(payment_info)      uuid = payment_info[:uuid]      name = payment_info[:name]      email = payment_info[:email]        user = User.find_by(uuid: uuid)      return user if user.present?        user = User.create(        uuid: uuid,        name: name,        email: email      )      user    end  end  

UPDATE

controller/subscriptions_controller.rb

 def create        # Some logic ....        rescue CreateSubscription::UserCreateError => e          # TODO: This should be an array, not only each one          render json: { error: e.message }, status: :bad_request  

Unable to connect to Geckodriver

Posted: 26 Sep 2016 02:45 AM PDT

I'm trying to run the exsample scirpt of Selenium with Ruby on Rails. I've to run it with a proxy. Here's my code:

    require 'rubygems'  require 'bundler/setup'    # require your gems as usual  require "selenium-webdriver"    Selenium::WebDriver::Firefox.path = "/home/marc/Documents/firefox/firefox"  profile = Selenium::WebDriver::Firefox::Profile.new  proxy = Selenium::WebDriver::Proxy.new(:http => nil)  profile.proxy = proxy  driver = Selenium::WebDriver.for :firefox, :profile => profile  driver.navigate.to "http://google.com"    element = driver.find_element(:name, 'q')  element.send_keys "Hello WebDriver!"  element.submit    puts driver.title    driver.quit  

I got the following error:

/home/marc/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/selenium-webdriver-3.0.0.beta3.1/lib/selenium/webdriver/common/service.rb:115:in `connect_until_stable': unable to connect to Mozilla geckodriver 127.0.0.1:4445 (Selenium::WebDriver::Error::WebDriverError)  

Can someone help me...? I'm trying since hours and can't find the problem... Really don't know what to do.

I'm using: Ubuntu 16.04 LTS Firefox 45.0 rbenv 2.3.1

Other question: Someone knows some example for Selenium + Ruby on Rails? With google i can't find really good stuff... the documentation is really poor :(

Invalid dropzone element in rails

Posted: 26 Sep 2016 02:39 AM PDT

I'm trying to add dropzone to a rails app. I have not come to rails part yet. Because dropzone setting up getting this error;

Error: Invalid dropzone element.      at new Dropzone (http://localhost:3000/theme/components/dropzone/dist/dropzone.js:424:15)      at HTMLDocument.<anonymous> (http://localhost:3000/galleries/new:645:30)      at fire (http://localhost:3000/theme/components/jquery/dist/jquery.js:3182:31)      at Object.fireWith [as resolveWith] (http://localhost:3000/theme/components/jquery/dist/jquery.js:3312:7)      at Function.ready (http://localhost:3000/theme/components/jquery/dist/jquery.js:3531:13)      at HTMLDocument.completed (http://localhost:3000/theme/components/jquery/dist/jquery.js:3547:9)  

Here is the script part;

jQuery(function($){        try {          Dropzone.autoDiscover = false;            var myDropzone = new Dropzone('#dropzone', {              previewTemplate: $('#preview-template').html(),                thumbnailHeight: 120,              thumbnailWidth: 120,              maxFilesize: 0.5,                //addRemoveLinks : true,              //dictRemoveFile: 'Remove',                dictDefaultMessage :              '<span class="bigger-150 bolder"><i class="ace-icon fa fa-caret-right red"></i> Drop files</span> to upload \              <span class="smaller-80 grey">(or click)</span> <br /> \              <i class="upload-icon ace-icon fa fa-cloud-upload blue fa-3x"></i>'              ,                thumbnail: function(file, dataUrl) {                  if (file.previewElement) {                  $(file.previewElement).removeClass("dz-file-preview");                  var images = $(file.previewElement).find("[data-dz-thumbnail]").each(function() {                      var thumbnailElement = this;                      thumbnailElement.alt = file.name;                      thumbnailElement.src = dataUrl;                  });                  setTimeout(function() { $(file.previewElement).addClass("dz-image-preview"); }, 1);                  }              }                });                  //simulating upload progress              var minSteps = 6,                  maxSteps = 60,                  timeBetweenSteps = 100,                  bytesPerStep = 100000;                myDropzone.uploadFiles = function(files) {              var self = this;                for (var i = 0; i < files.length; i++) {                  var file = files[i];                      totalSteps = Math.round(Math.min(maxSteps, Math.max(minSteps, file.size / bytesPerStep)));                    for (var step = 0; step < totalSteps; step++) {                      var duration = timeBetweenSteps * (step + 1);                      setTimeout(function(file, totalSteps, step) {                          return function() {                          file.upload = {                              progress: 100 * (step + 1) / totalSteps,                              total: file.size,                              bytesSent: (step + 1) * file.size / totalSteps                          };                            self.emit('uploadprogress', file, file.upload.progress, file.upload.bytesSent);                          if (file.upload.progress == 100) {                              file.status = Dropzone.SUCCESS;                              self.emit("success", file, 'success', null);                              self.emit("complete", file);                              self.processQueue();                          }                          };                      }(file, totalSteps, step), duration);                  }              }          }              //remove dropzone instance when leaving this page in ajax mode          $(document).one('ajaxloadstart.page', function(e) {              try {                  myDropzone.destroy();              } catch(e) {}          });        } catch(e) {          alert('Dropzone.js does not support older browsers!');          console.log(e);      }    });  

And here is the html part;

<div>      <form action="../dummy.html" class="dropzone well" id="dropzone">          <div class="fallback">              <input name="file" type="file" multiple="" />          </div>      </form>  </div>    <div id="preview-template" class="hide">      Some codes...  </div>  

This code snippet doesn't solve my issue.

Dropzone.autoDiscover = false;  

Also past same questions doesn't solve my issue.

An error occurred while installing rmagick (2.16.0) [I tried all option provided in Duplicate but same issue persisit]

Posted: 26 Sep 2016 03:30 AM PDT

I 'm on Ubuntu 16.04 , in gemfile I have gem "rmagick" and when I bundle it says

An error occurred while installing rmagick (2.16.0), and Bundler cannot  continue.  Make sure that `gem install rmagick -v '2.16.0'` succeeds before bundling.  

as suggested above when I try gem install rmagick -v '2.16.0' it says

Building native extensions.  This could take a while...  ERROR:  Error installing rmagick:      ERROR: Failed to build gem native extension.        current directory: /home/faisal/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rmagick-2.16.0/ext/RMagick  /home/faisal/.rbenv/versions/2.3.1/bin/ruby -r ./siteconf20160926-26223-16sn0dg.rb extconf.rb  checking for gcc... yes  checking for Magick-config... no  checking for pkg-config... yes  Package MagickCore was not found in the pkg-config search path.  Perhaps you should add the directory containing `MagickCore.pc'  to the PKG_CONFIG_PATH environment variable  No package 'MagickCore' found  checking for outdated ImageMagick version (<= 6.4.9)... *** extconf.rb failed ***  Could not create Makefile due to some reason, probably lack of necessary  libraries and/or headers.  Check the mkmf.log file for more details.  You may  need configuration options.    Provided configuration options:      --with-opt-dir      --without-opt-dir      --with-opt-include      --without-opt-include=${opt-dir}/include      --with-opt-lib      --without-opt-lib=${opt-dir}/lib      --with-make-prog      --without-make-prog      --srcdir=.      --curdir      --ruby=/home/faisal/.rbenv/versions/2.3.1/bin/$(RUBY_BASE_NAME)    To see why this extension failed to compile, please check the mkmf.log which can be found here:      /home/faisal/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0-static/rmagick-2.16.0/mkmf.log    extconf failed, exit code 1    Gem files will remain installed in /home/faisal/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rmagick-2.16.0 for inspection.  Results logged to /home/faisal/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0-static/rmagick-2.16.0/gem_make.out  

I have tried dozen of different ways provided in different questions but none of the work.

RestClient not uploading multiple files

Posted: 26 Sep 2016 02:29 AM PDT

I am trying to call external API and send attachments. Following is working example of curl and multiple attachment

curl -v -u xxxx@domain.in:password -F "helpdesk_ticket[attachments][][resource]=@/tmp/upload_test_1.txt" -F "helpdesk_ticket[attachments][][resource]=@/tmp/upload_test_2.txt" -F "helpdesk_ticket[email]=testemail@domain.in" -F "helpdesk_ticket[priority]=1" -F "helpdesk_ticket[source]=2" -F "helpdesk_ticket[status]=2" -F "helpdesk_ticket[subject]=TestingSubject" -F "helpdesk_ticket[description]=testingcontent" -X POST url

With this curl request i am able to send and upload multiple attachment. But when i am doing same using my Rails Rest client code its not uploading all attachment its uploading only 1 attachment.

RestClient::Request.execute(url: "url", method: :post, payload: {"helpdesk_ticket"=>{"description"=>"testingcontent", "subject"=>"TEstingsubject", "email"=>"email@domain.in", "priority"=>1, "source"=>2, "status"=>2, "attachments"=>[{"resource"=> File.new('/tmp/upload_test_1.txt')},{"resource"=> File.new('/tmp/upload_test_2.txt')}], "cc_emails"=>[], "multipart"=>true}, user: "email@domain.in", password: "password", timeout: 10)

Any suggestion would be appreciated.

Multiple optional parameters in a route -- how?

Posted: 26 Sep 2016 07:48 AM PDT

I want to create a scope with 2 optional parameters. The 1st one can only be "parameter1" or omitted completely and the 2nd one can only have values of "a or b or c" or also omitted. How can I do that?

1 comment:

  1. Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking. Ruby on Rails Online Training

    ReplyDelete