Ruby on rails

Need to select tasks based on task_type

I have an html page where i am showing dynamic data. I need to show only selected data. As you can see below it is showing data for all tasks. I have 4 types of task_type i.e “work, reminder, work-off, estimate” I only want to show data for task_type = “work” <tbody> {% for task in job.tasks %} <tr> <td>…
Read more

Yard and C extension

I have a C ruby extension that I document with rdoc. There are both C files and ruby files that are parsed by rdoc. Does yard can do the same and is there an “easy way”, (I mean a commonly used way) to migrate from rdoc to yard? Source: ruby

Ruby on Rails: Open Modal Box Link doesn’t work

I want my page to open a Modal Popup Box, so I added this link to my view file: <%= link_to_remote ‘+ Add Discount’, :url => {:controller => “parent_wise_fee_payments”, :action => “new_instant_discount”, :id =>, :current_action => @target_action, :current_controller => @target_controller} %> and in the controller: def new_instant_discount @financefee=FinanceFee.find(params[:id]) @target_action=params[:current_action] @target_controller=params[:current_controller] @finance_fee_category=@financefee.finance_fee_collection.fee_category respond_to do |format| format.js { render :action =>…
Read more

ArgumentError in StaticPages#manager

I have a problem with item creation. I have next error: First argument in form cannot contain nil or be empty on the second line of this code (app/view/items/new.html.erb): <h1>Items manage</h1> <%= form_for @item do |f| %> <%= f.text_field :variable1 %> <%= f.text_field :variable2 %> <%= f.text_field :variable3 %> <%= f.text_field :variable4 %> <%= f.text_field :value1 %> <%= f.text_field :value2…
Read more

Bluemix Ruby app health check configuration

We have a Sinatra app that is deployed to Bluemix through the Bluemix Ruby service. However, the app is made unavailable after a while, and we suspect that the Bluemix health check is failing. We can see that there is periodic calls to the root (i.e the / route) from something we think is the Bluemix load balancer. However, our…
Read more

Ruby open-uri proxy authentication fails

I’m coding a native Ruby script to scrap a website using Nokogiri, whenever I pass proxy options to the open-uri open() method, it returns 407 Proxy Authentication Required but my options does have the authentification details, here’s my code proxy_url = URI.parse(“http://12.34.567.89:PORT”) session = Nokogiri::HTML(open(“”, :proxy_http_basic_authentication =>[proxy_url, “username”, “password”] Note: As my proxy is premium, I have replaced real proxy…
Read more

how to make sure nginx is running

I’ve installed rvm, ruby, rails, passenger, and nginx using this tutorial. However, I’ve installed it all over ssh connecting with myusername@machine-ssh-url. So now I’ve started nginx using service nginx start But I’d like to make sure it’s working before moving on. The tutorial states “nginx is now on. You can see the exciting “Welcome to nginx” screen in your browser…
Read more

Ruby PHP equivalent

Any idea how can I get the same result as with Ruby in PHP? Unix epoch time. timeint = puts timeint Result: 1443253948 Thank you! I tried but not much good result. EDIT: Seems this does the trick, never thought about: $epoch = time(); EDIT OFFTOPIC: seems there are many trolls here that instead of helping they just…
Read more

Sort an array of objects in ruby using "sort"

How can I sort this array so all hashes with optional = true are last? my_array = [ { name: “foo”, optional: true }, { name: “pop” }, { name: “boop”, optional: true }, { name: “pop”, optional: false } ] I tried this: my_array.sort { |a,b| a[‘optional’] <=> b[‘optional’] } But I get this error: comparison of Hash with…
Read more