Questions tagged as 'ruby-on-rails'

1
answer

Nested objects has_one rails 4

Talk to people, I'm new to rails and I'm trying to make a crud with two objects, a Project and another Album. Project has_one Album, as test each only has one: name as parameter, but I can not create a Project with album. Here's my code: p...
asked by 22.01.2016 / 20:50
1
answer

Select complex in ruby on rails

I have a model that describes the friendship between my users: #CreateFriendship.rb class CreateFriendships < ActiveRecord::Migration def change create_table :friendships do |t| t.integer :user_id t.integer :friend_id...
asked by 28.01.2016 / 18:27
2
answers

Sort array in rails [closed]

I can not sort my array in descending order of id. <%@vendas = Vendas.find(:all,:order=>"id, DESC")%>     
asked by 22.02.2016 / 15:21
1
answer

verify if backend method is true and not client as well

I have a code that on my backend it returns true or false, I'm working with ruby and rails 5. So I have it's an if or so ja: <% if @order? %> <h2> teste 2 <h2> <%else> <h1>teste 1</h1> <%end>...
asked by 05.11.2015 / 18:06
1
answer

Upgrading a site to a newer version of Rails

How do you upgrade a site developed in Ruby on Rails to a newer version of Rails? For example from 4.2.4 for a possible Rails 5.0.0. I am still a beginner in the language and framework and I was left with this doubt if for example I develo...
asked by 25.09.2015 / 15:17
1
answer

Ruby on Rails - Randomize JSON variable and apply in Array

Well, I have a problem that is relatively simple, but that is ending with me. I have an array of JSON objects. This array of objects will compose another array containing other n arrays. So far so good. However, what happens is that with...
asked by 09.11.2015 / 22:42
1
answer

Rails 4 + -jquery-datatable + ajax-datatable - Error 406 Http and ActionController :: UnknownFormat format json

I was studying rails and following the link tutorial. The steps in the tutorial were as follows, create a datatable that would make a request via json, the controller that would respond with the data and the data table would be populated....
asked by 15.09.2015 / 01:12
1
answer

Make condition inside the render

I'm learning Ruby and am having a question about how to make a if inside the render to display param only if it exists ... Ex: if params[:field] puts 'field' => params[:field], end How do I resolve this in this code?...
asked by 19.05.2015 / 23:01
1
answer

How to generate sequential numbers automatically with current year in rails?

I need when a new product is created it generates a number ex: 0001/2015 number / year_vigente and when change of year returns to zero. I made a helper just to format the number in the views, but it does not solve the problem of automatic gen...
asked by 15.05.2015 / 21:26
1
answer

Database configuration using rspec-rails

In my spec / rails_helper.rb I added the following code so that the database was automatically created when running rspec : def database_exists? ActiveRecord::Base.connection rescue ActiveRecord::NoDatabaseError ? false : true end unless...
asked by 24.04.2015 / 21:00