Questions tagged as 'ruby'

1
answer

Alphabetical order Ruby on Rails

I need to put my category in alphabetical order: @posts_categories = Admin::PostCategory.all     
asked by 19.01.2016 / 17:25
3
answers

Compare values of an array

I have an array and in this array I have some dates, and I need to print the dates that are repeated. In order to get this data I created a for the size of the array, and within that for I made another loop in case one is also to be able to comp...
asked by 05.07.2015 / 08:28
2
answers

Enable CORS in api rails

Using this GEM to enable CORS my application. The code I have in my config/application.rb is as follows: config.middleware.insert_before 0, 'Rack::Cors' do allow do origins 'http://localhost:8080' resource '*',...
asked by 02.06.2015 / 15:44
1
answer

How to execute JavaScript function on current page through Application Controller?

I'm doing a browser validation (IE < 10) through the Application Controller with gem "browser" . I need any JavaScript page with a message saying that browser is not recommended for any page of the application that is accessed. A...
asked by 10.06.2015 / 15:31
1
answer

Erase a flash [: success] a few seconds after being shown to the user?

I have a registration form using Rails, where after the user completes the registration, he is redirected to the login page along with a flash[:success] that shows a welcome message. My question is if I had some form in Rails itself to...
asked by 09.08.2015 / 02:22
1
answer

Problem creating Rails application

When I create an application, at the time of doing a scaffold (following tutorials) I get the following error: C:\Users\User\Usuarios>rails generate scaffold Usuario nome:string idade:integer C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sqlite3-1...
asked by 28.04.2015 / 19:47
1
answer

How do I add more rows to a class in Ruby?

I started to venture into the rubygems world. I am developing a gem to generate the assets of my twitter bootstrap-style application, since I intend to reuse my front-end code. All I need to do is put the assets in the correct places, add some h...
asked by 23.03.2015 / 13:41
2
answers

Initialization of instance variables in ActiveRecord

I am having trouble initializing instance variables in Rails, I need to use a variable in several methods, but this needs to be initialized beforehand, for example: class Test < ActiveRecord::Base @test = 1 def testar @test+1...
asked by 19.11.2014 / 14:47
2
answers

NoMethodError in Users # show

I'm learning Rails, following a book that has the following code: UserController class UsersController < ApplicationController def new @user = User.new end def edit @user = User.find(params[:id]) end def show @user =...
asked by 05.02.2014 / 17:55
1
answer

How to make routes with optional and ordered parameters in Rails 4?

How do I make a route like this? site.com/clothing/men/T-Shirts_type/Nike_brand/100-500_price/Red,White,Blue_color/ site.com/clothing/woman/Nike_brand/100-500_price/Red,White,Blue_color/ It should always be in the following order: site.c...
asked by 20.02.2014 / 13:40