GitHub activity

@vairix-garbeletche
vairix-garbeletche pushed to develop-agesic in maccio8/consul
Feb 16, 2018
@vairix-garbeletche
vairix-garbeletche pushed to develop-agesic in vairix-garbeletche/consul
  • @vairix-garbeletche a091b87
    generate task setting data (#16)
Feb 16, 2018
@vairix-garbeletche
Feb 16, 2018
generate task setting data #16

What add generic task, set data setting

+11 -1
@vairix-garbeletche
Feb 16, 2018
generate task setting data #16

What add generic task, set data setting

+11 -1
@vairix-garbeletche
vairix-garbeletche pushed to develop-agesic in vairix-garbeletche/consul
  • @vairix-garbeletche 7899ab4
    change presence validate proposals (#15)
Feb 15, 2018
@vairix-garbeletche
Feb 15, 2018
change presence validate proposals #15

What remove presence question to proposal add presence geozone to proposal remove text-field question to proposal new change text geozone in propo…

+18 -22
@vairix-garbeletche
Feb 15, 2018
change presence validate proposals #15

What remove presence question to proposal add presence geozone to proposal remove text-field question to proposal new change text geozone in propo…

+18 -22
@vairix-garbeletche
vairix-garbeletche pushed to develop-agesic in vairix-garbeletche/consul
  • @casikami 4a8fee8
    remove items from menu (#14)
Feb 15, 2018
@vairix-garbeletche
Feb 15, 2018
remove items from menu #14

What remove items from menu

+1 -2
@vairix-garbeletche
vairix-garbeletche pushed to develop-agesic in vairix-garbeletche/consul
  • @casikami 5c7192b
    proposal and more info (#13)
Feb 15, 2018
@vairix-garbeletche
Feb 15, 2018
proposal and more info #13

What change text and navsfrom proposal and more info

+306 -19
@vairix-garbeletche
Feb 15, 2018
@vairix-garbeletche
Feb 15, 2018
@vairix-garbeletche
vairix-garbeletche pushed to develop-agesic in vairix-garbeletche/consul
  • @leoburgos 6cd7cd6
    Fixes nested documents on comments (#8)
Feb 15, 2018
@vairix-garbeletche
Feb 15, 2018
Fixes nested documents on comments #8

Where Related Issue: LINK_OR_#_REF Related PR's: LINK_OR_#_REF_IF_ANY What Whats the objective of this changes ? How How you implemented/achie…

+198 -1
@vairix-garbeletche
vairix-garbeletche pushed to bugfix/nested_comments_documents in vairix-garbeletche/consul
  • @vairix-garbeletche 262ae90
    new file create.js.erb in custom comments
Feb 15, 2018
@vairix-garbeletche
vairix-garbeletche deleted branch feature/proposal-text at vairix-garbeletche/consul
Feb 15, 2018
@vairix-garbeletche
vairix-garbeletche pushed to feature/add_saml_login in vairix-garbeletche/consul
  • @vairix-garbeletche 4e1d362
    add iduruguay to option login
Feb 15, 2018
@vairix-garbeletche
vairix-garbeletche pushed to develop-agesic in vairix-garbeletche/consul
  • @vairix-garbeletche 5c712f4
    header footer index (#11)
Feb 15, 2018
@vairix-garbeletche
Feb 15, 2018
header footer index #11

What change text in the home

+158 -63
@vairix-garbeletche
vairix-garbeletche pushed to develop-agesic in vairix-garbeletche/consul
  • @vairix-garbeletche 8f28aab
    change text to organism (#12)
Feb 15, 2018
@vairix-garbeletche
Feb 15, 2018
change text to organism #12

What change text to organism

+8 -6
@vairix-garbeletche
Feb 15, 2018
change text to organism #12

What change text to organism

+8 -6
@vairix-garbeletche
Feb 15, 2018
@vairix-garbeletche
Feb 15, 2018
header footer index #11

What change text in the home

+132 -63
@vairix-garbeletche
vairix-garbeletche pushed to develop-agesic in vairix-garbeletche/consul
  • @leoburgos b71bb49
    Adds setting to allow only admins to create proposals (#9)
Feb 14, 2018
@vairix-garbeletche
Feb 14, 2018
Adds setting to allow only admins to create proposals #9

Where Related Issue: LINK_OR_#_REF Related PR's: LINK_OR_#_REF_IF_ANY What Whats the objective of this changes ? How How you implemented/achie…

+23 -4
@vairix-garbeletche
vairix-garbeletche pushed to feature/add_admin_proposal_setting in vairix-garbeletche/consul
Feb 14, 2018
@vairix-garbeletche
Feb 14, 2018
@vairix-garbeletche
Feb 14, 2018
social media #10

Where in proposal What update text to share proposal

+87 -0
@vairix-garbeletche
Feb 14, 2018
social media #10

Where in proposal What update text to share proposal

+87 -0
@vairix-garbeletche
vairix-garbeletche pushed to develop-agesic in vairix-garbeletche/consul
  • @leoburgos 2a87eb9
    Adds validation for proposals date range on controllers (#7)
Feb 14, 2018
@vairix-garbeletche
Feb 14, 2018
Adds validation for proposals date range on controllers #7

Where Related Issue: LINK_OR_#_REF Related PR's: LINK_OR_#_REF_IF_ANY What Whats the objective of this changes ? How How you implemented/achie…

+7 -0
@vairix-garbeletche
vairix-garbeletche pushed to develop-agesic in vairix-garbeletche/consul
  • @leoburgos 76d314a
    Adds search by comments on proposals advanced search (#6)
Feb 14, 2018
@vairix-garbeletche
Feb 14, 2018
Adds search by comments on proposals advanced search #6

Where Related Issue: LINK_OR_#_REF Related PR's: LINK_OR_#_REF_IF_ANY What Whats the objective of this changes ? How How you implemented/achie…

+11 -1
@vairix-garbeletche
Feb 14, 2018

Deberiamos usar ILIKE sino me equivoco para que busque tanto por mayusculas como minusculas.

@vairix-garbeletche
vairix-garbeletche pushed to test in IntendenciaMontevideo/consul
  • @vairix-garbeletche 55db5bd
    Feature/add tag analytics (#40)
Feb 9, 2018
@vairix-garbeletche
Feb 9, 2018
Feature/add tag analytics #40

add facebook script

+29 -1
@vairix-garbeletche
Feb 9, 2018
Feature/add tag analytics #40

add facebook script

+29 -1
@vairix-garbeletche
vairix-garbeletche pushed to develop-agesic in maccio8/consul
  • @leoburgos e6b7a45
    Adds date range settings for modifying proposals (#5)
Feb 8, 2018
@vairix-garbeletche
vairix-garbeletche pushed to develop-agesic in vairix-garbeletche/consul
  • @leoburgos e6b7a45
    Adds date range settings for modifying proposals (#5)
Feb 8, 2018
@vairix-garbeletche
Feb 8, 2018
Adds date range settings for modifying proposals #5

Where Related Issue: LINK_OR_#_REF Related PR's: LINK_OR_#_REF_IF_ANY What Whats the objective of this changes ? How How you implemented/achie…

+762 -12
@vairix-garbeletche
Feb 8, 2018
@vairix-garbeletche
vairix-garbeletche pushed to feature/proposal_date_range in vairix-garbeletche/consul
  • @vairix-garbeletche af7c235
    change js a cusmtom file, add task proposal date
Feb 8, 2018
@vairix-garbeletche
Feb 7, 2018
@vairix-garbeletche
vairix-garbeletche pushed to develop-agesic in vairix-garbeletche/consul
Feb 7, 2018
@vairix-garbeletche
Feb 7, 2018
Feature/add document to comment #2

add document to comment

+38 -5
@vairix-garbeletche
vairix-garbeletche pushed to develop-agesic in vairix-garbeletche/consul
Feb 7, 2018
@vairix-garbeletche
Feb 7, 2018
generate script initials #4

generate script initial modules Run it this way In production: RAILS_ENV=produciton rake initial_modules:set_module or RAILS_ENV=produciton bundle …

+24 -0
@vairix-garbeletche
Feb 7, 2018
generate script initials #4

generate script initial modules Run it this way In production: RAILS_ENV=produciton rake initial_modules:set_module or RAILS_ENV=produciton bundle …

+24 -0
@vairix-garbeletche
vairix-garbeletche closed a pull request in consul/consul
Feb 7, 2018
Feature/generate script initials #2451

generate script initial modules Run it this way In production: RAILS_ENV=produciton rake initial_modules:set_module or RAILS_ENV=produciton bundle …

+98 -1
@vairix-garbeletche
vairix-garbeletche opened a pull request in consul/consul
Feb 7, 2018
Feature/generate script initials #2451

generate script initial modules Run it this way In production: RAILS_ENV=produciton rake initial_modules:set_module or RAILS_ENV=produciton bundle …

+98 -1
@vairix-garbeletche
vairix-garbeletche pushed to develop-agesic in vairix-garbeletche/consul
Feb 7, 2018
@vairix-garbeletche
Feb 7, 2018
Adds organism field to comments and creates custom views to show and … #1

adds organism field to comments and creates custom views

+182 -6
@vairix-garbeletche
Feb 7, 2018
Feature/add saml login #3

Connect wit ID URuguay

+363 -18
@vairix-garbeletche
Feb 7, 2018
Feature/add document to comment #2

add document to comment

+161 -1
@vairix-garbeletche
Feb 7, 2018
Adds organism field to comments and creates custom views to show and … #1

adds organism field to comments and creates custom views

+178 -4
@vairix-garbeletche
vairix-garbeletche pushed to feature/add_document_to_comment in vairix-garbeletche/consul
  • @vairix-garbeletche 100e652
    Moves changes from views to custom views
Feb 6, 2018
@vairix-garbeletche
Jan 31, 2018
@vairix-garbeletche
vairix-garbeletche pushed to test in IntendenciaMontevideo/consul
Jan 30, 2018
@vairix-garbeletche
Jan 25, 2018
@vairix-garbeletche
Jan 22, 2018
changes #39

What chance text requested by client

+16 -14
@vairix-garbeletche
Jan 22, 2018
@vairix-garbeletche
Jan 22, 2018
law erased #38

What remove cose un condiciones anda policy

+0 -2
@vairix-garbeletche
Jan 22, 2018
law erased #38

What remove cose un condiciones anda policy

+0 -2
@vairix-garbeletche
vairix-garbeletche pushed to test in IntendenciaMontevideo/consul
  • @vairix-garbeletche 90d5861
    law add on conditions an privacy (#37)
Jan 18, 2018
@vairix-garbeletche
Jan 18, 2018
+4 -1
@vairix-garbeletche
Jan 18, 2018
+4 -1
@vairix-garbeletche
Jan 17, 2018
@vairix-garbeletche
vairix-garbeletche pushed to test in IntendenciaMontevideo/consul
  • @vairix-garbeletche 82d010e
    law add on conditions an privacy (#36)
Jan 15, 2018
@vairix-garbeletche
Jan 15, 2018
law add on conditions an privacy #36

What add test to terms and conditions

+4 -1
@vairix-garbeletche
Jan 15, 2018
law add on conditions an privacy #36

What add test to terms and conditions

+4 -1
@vairix-garbeletche
vairix-garbeletche pushed to test in IntendenciaMontevideo/consul
  • @vairix-garbeletche 844f5e7
    Feature/content bug (#35)
Jan 12, 2018
@vairix-garbeletche
Jan 12, 2018
Feature/content bug #35

What fix error style in debates

+59 -15
@vairix-garbeletche
Jan 12, 2018
Feature/content bug #35

What fix error style in debates

+59 -15
@vairix-garbeletche
vairix-garbeletche pushed to feature/content-bug in IntendenciaMontevideo/consul
  • @vairix-garbeletche c640f73
    ideas and presupuesto participativo text align
Jan 12, 2018
@vairix-garbeletche
vairix-garbeletche pushed to test in IntendenciaMontevideo/consul
  • @vairix-garbeletche 70f1de7
    ideas and presupuesto participativo text align (#34)
Jan 12, 2018
@vairix-garbeletche
Jan 12, 2018
ideas and presupuesto participativo text align #34

What change style in responsive

+51 -10
@vairix-garbeletche
Jan 12, 2018
ideas and presupuesto participativo text align #34

What change style in responsive

+51 -10


StackOverflow activity

Answer by VAIRIX for How to make a discourse plugin available for public posts?

Disclosure: user @dariomac, the question owner, is part of our organization.

You have to skip the ensure_logged_in in the before_filter of the controller. Add something like this line to your plugin controller:

skip_before_filter :ensure_logged_in, only: :

Answer by VAIRIX for How to make a discourse plugin available for public posts?

Disclosure: user @dariomac, the question owner, is part of our organization.

You have to skip the ensure_logged_in in the before_filter of the controller. Add something like this line to your plugin controller:

skip_before_filter :ensure_logged_in, only: :

Answer by VAIRIX for reduce verbose jquery if else statement

I think that something like this, would be helpful to save up some lines of code in the js file.

  $("button").click(function () {        
    var a = '<'+this.innerHTML+'>';
    var b = '</'+this.innerHTML+'>';

    alert(a + 'put here the text to translate into our language. each one corresponds to a different alien dialect' + b);
  });

If you want to reduce the html to. I recommended to you that generate the buttons dynamically. You can generate an array as follow:

var array = new Array();
array['andromeda'] = '‡¦';
array['milkway'] = '¬';
array['alien-alpha'] = '¬y';
...

and then iterate for generate the buttons and append it to the html.

Answer by VAIRIX for reduce verbose jquery if else statement

I think that something like this, would be helpful to save up some lines of code in the js file.

  $("button").click(function () {        
    var a = '<'+this.innerHTML+'>';
    var b = '</'+this.innerHTML+'>';

    alert(a + 'put here the text to translate into our language. each one corresponds to a different alien dialect' + b);
  });

If you want to reduce the html to. I recommended to you that generate the buttons dynamically. You can generate an array as follow:

var array = new Array();
array['andromeda'] = '‡¦';
array['milkway'] = '¬';
array['alien-alpha'] = '¬y';
...

and then iterate for generate the buttons and append it to the html.

Answer by VAIRIX for Passing a child to container of parent type

The way I've solve this in my projects, is using instance_ofsome_class.individuals << student_instance.individual.

The thing here is that is not a real MTI, so your collection of individuals would accept only individuals instances. If you call some_student_instance.individual or some_professor_instance.individual, you'll get an individual instance which is related with your specific instance. Then working with that collection, if you want a Student or Professor all you need to do is call individual_in_collection.specific. For example:

p = Professor.create
a_model.individuals << p.individual
puts "#{a_model.individuals.first.class.name}"
=> Individual
puts "#{a_model.individuals.first.specific.class.name}"
=> Professor
Answer by VAIRIX for Passing a child to container of parent type

The way I've solve this in my projects, is using instance_ofsome_class.individuals << student_instance.individual.

The thing here is that is not a real MTI, so your collection of individuals would accept only individuals instances. If you call some_student_instance.individual or some_professor_instance.individual, you'll get an individual instance which is related with your specific instance. Then working with that collection, if you want a Student or Professor all you need to do is call individual_in_collection.specific. For example:

p = Professor.create
a_model.individuals << p.individual
puts "#{a_model.individuals.first.class.name}"
=> Individual
puts "#{a_model.individuals.first.specific.class.name}"
=> Professor
Answer by VAIRIX for Devise: User for subdomains

When you add the validatable module of devise in your model, automatically devise adds the follow validations:

 devise/lib/devise/models/validatable.rb

# All validations used by this module.
  VALIDATIONS = [ :validates_presence_of, :validates_uniqueness_of, :validates_format_of,
                  :validates_confirmation_of, :validates_length_of ].freeze


  def self.included(base)
    base.extend ClassMethods
    assert_validations_api!(base)

    base.class_eval do
      validates_presence_of   :email, if: :email_required?
      validates_uniqueness_of :email, allow_blank: true, if: :email_changed?
      validates_format_of     :email, with: email_regexp, allow_blank: true, if: :email_changed?

      validates_presence_of     :password, if: :password_required?
      validates_confirmation_of :password, if: :password_required?
      validates_length_of       :password, within: password_length, allow_blank: true
    end
  end

So, you could remove the validatable module and make your owns validations.

Answer by VAIRIX for Devise: User for subdomains

When you add the validatable module of devise in your model, automatically devise adds the follow validations:

 devise/lib/devise/models/validatable.rb

# All validations used by this module.
  VALIDATIONS = [ :validates_presence_of, :validates_uniqueness_of, :validates_format_of,
                  :validates_confirmation_of, :validates_length_of ].freeze


  def self.included(base)
    base.extend ClassMethods
    assert_validations_api!(base)

    base.class_eval do
      validates_presence_of   :email, if: :email_required?
      validates_uniqueness_of :email, allow_blank: true, if: :email_changed?
      validates_format_of     :email, with: email_regexp, allow_blank: true, if: :email_changed?

      validates_presence_of     :password, if: :password_required?
      validates_confirmation_of :password, if: :password_required?
      validates_length_of       :password, within: password_length, allow_blank: true
    end
  end

So, you could remove the validatable module and make your owns validations.

Answer by VAIRIX for Rails STI: How to change mapping between class name & value of the 'type' column

You can try something like this:

class Proyect < ActiveRecord::Base
end

Then the Indoor class but with Other name

class Other < Proyect
  class << self
    def find_sti_class(type_name)
      type_name = self.name
      super
    end

    def sti_name
      "Indoor"
    end
  end
end

The same apply for Outdoor class. You can check sti_name in http://apidock.com/rails/ActiveRecord/Base/find_sti_class/class

Answer by VAIRIX for Rails STI: How to change mapping between class name & value of the 'type' column

You can try something like this:

class Proyect < ActiveRecord::Base
end

Then the Indoor class but with Other name

class Other < Proyect
  class << self
    def find_sti_class(type_name)
      type_name = self.name
      super
    end

    def sti_name
      "Indoor"
    end
  end
end

The same apply for Outdoor class. You can check sti_name in http://apidock.com/rails/ActiveRecord/Base/find_sti_class/class

Comment by VAIRIX on Rails app crashes when config.eager_load=true
Have you tried to put <code>:require => false</code> to your engine in the Gemfile of the main app. By doing this, your gem would only be loaded when required instead of at boot time.
Comment by VAIRIX on Rails app crashes when config.eager_load=true
Have you tried to put <code>:require => false</code> to your engine in the Gemfile of the main app. By doing this, your gem would only be loaded when required instead of at boot time.
Answer by VAIRIX for Use where on has_many :through to find objects with 2 certain child object from different classes (Rails 4)

You need to do something like this:

User.joins(:carmodels).joins(:professors)
Answer by VAIRIX for Use where on has_many :through to find objects with 2 certain child object from different classes (Rails 4)

You need to do something like this:

User.joins(:carmodels).joins(:professors)
Comment by VAIRIX on Fixing git double-commit history
What comes to my mind is that you could make a change the commits order first to gather those who want to do the squash. To change the order you just got to swap the lines of the commit in the file that opens the git rebase -i. On the other side to see if the commits are equal or not, I would use gitg tool, to check the commits that have the same name and verify if those commits have the same changes. I don't know if there is any tool to automatically compare.
Comment by VAIRIX on Fixing git double-commit history
What comes to my mind is that you could make a change the commits order first to gather those who want to do the squash. To change the order you just got to swap the lines of the commit in the file that opens the git rebase -i. On the other side to see if the commits are equal or not, I would use gitg tool, to check the commits that have the same name and verify if those commits have the same changes. I don't know if there is any tool to automatically compare.
Comment by VAIRIX on Fixing git double-commit history
I don't understand your first question... can you explain me more detailed? Otherwise, to rename the commit, you have to use 'edit' instead of squash, save the file, and then git commit --amend. This open an editor and you have to save the file with the new name of the commit.
Comment by VAIRIX on Fixing git double-commit history
I don't understand your first question... can you explain me more detailed? Otherwise, to rename the commit, you have to use 'edit' instead of squash, save the file, and then git commit --amend. This open an editor and you have to save the file with the new name of the commit.
Answer by VAIRIX for Fixing git double-commit history

The command to accomplish that is:

git rebase -i HEAD~7

This will open up your editor with something like this:

pick f392171 Removed most clearfixs in templates
pick ba9dd9a Removed most clearfixs in templates
pick df71a27 Unew redirect logic
pick 79ce782 Merge branch 'develop' of github.com:xxx/xxx into develop
pick 1383070 Merge branch 'develop' of github.com:xxx/xxx into develop
...

Now you can tell git what to do with each commit. Let's keep the commit f392171, the one were we added our feature. We'll squash the following two commits into the first one - leaving us with one clean.

Change your file to this:

pick f392171 Removed most clearfixs in templates
squash ba9dd9a Removed most clearfixs in templates
pick df71a27 Unew redirect logic
pick 79ce782 Merge branch 'develop' of github.com:xxx/xxx into develop
squash 1383070 Merge branch 'develop' of github.com:xxx/xxx into develop

When you save and exit the editor, Git applies all two changes and then puts you back into the editor to merge the three commit messages:

# This is a combination of  commits.
# The first commit's message is:
Removed most clearfixs in templates

# This is the 2nd commit message:

Removed most clearfixs in templates

When done, save and quit your editor. Git will now squash the commits into one. All done!

Then you have to do

git push origin your-branch -f

to force your locally commits changes into remote branch.

Note: You have to do a squash to every duplicated commit.

Answer by VAIRIX for Fixing git double-commit history

The command to accomplish that is:

git rebase -i HEAD~7

This will open up your editor with something like this:

pick f392171 Removed most clearfixs in templates
pick ba9dd9a Removed most clearfixs in templates
pick df71a27 Unew redirect logic
pick 79ce782 Merge branch 'develop' of github.com:xxx/xxx into develop
pick 1383070 Merge branch 'develop' of github.com:xxx/xxx into develop
...

Now you can tell git what to do with each commit. Let's keep the commit f392171, the one where we added our feature. We'll squash the following two commits into the first one - leaving us with one clean.

Change your file to this:

pick f392171 Removed most clearfixs in templates
squash ba9dd9a Removed most clearfixs in templates
pick df71a27 Unew redirect logic
pick 79ce782 Merge branch 'develop' of github.com:xxx/xxx into develop
squash 1383070 Merge branch 'develop' of github.com:xxx/xxx into develop

When you save and exit the editor, Git applies all two changes and then puts you back into the editor to merge the three commit messages:

# This is a combination of  commits.
# The first commit's message is:
Removed most clearfixs in templates

# This is the 2nd commit message:

Removed most clearfixs in templates

When done, save and quit your editor. Git will now squash the commits into one. All done!

Then you have to do

git push origin your-branch -f

to force your locally commits changes into remote branch.

Note: You have to do a squash to every duplicated commit.

Comment by VAIRIX on set css value with variable and unity
You need to concatenate the values. Something like this: t_number+'em'.
Comment by VAIRIX on set css value with variable and unity
You need to concatenate the values. Something like this: t_number+'em'.
Answer by VAIRIX for set css value with variable and unity

This should work:

var t_number = '3em';
$("#spacing #text_content").css("letter-spacing", t_number);
Answer by VAIRIX for set css value with variable and unity

This should work:

var t_number = '3em';
$("#spacing #text_content").css("letter-spacing", t_number);
Comment by VAIRIX on RSpec routing spec fails for custom match
Could you say me your rspec version?
Comment by VAIRIX on RSpec routing spec fails for custom match
Could you say me your rspec version?
Answer by VAIRIX for Joining a table and a filtered table in ActiveRecord

You can do something like this:

Song.joins(:albums).where('albums.released_on >= ?', from).where('albums.rating > ?', rating).where('albums.genre = ?', genres)

It makes only one query.

Answer by VAIRIX for Joining a table and a filtered table in ActiveRecord

You can do something like this:

Song.joins(:albums).where('albums.released_on >= ?', from).where('albums.rating > ?', rating).where('albums.genre = ?', genres)

It makes only one query.

Answer by VAIRIX for In Rails 4 using AJAX, how do I update a particular div on success?

This should work for you:

html = render_to_string(partial: 'images', locals: {user: user})
Answer by VAIRIX for In Rails 4 using AJAX, how do I update a particular div on success?

This should work for you:

html = render_to_string(partial: 'images', locals: {user: user})
Comment by VAIRIX on How to implement root route and get "index" to the same page
You can add root to: 'static_pages#index' inside or outside your scope. It's a possible solution and maybe doesn't fit what you expect, cause it takes more code to solve the problem.
Comment by VAIRIX on How to implement root route and get "index" to the same page
You can add root to: 'static_pages#index' inside or outside your scope. It's a possible solution and maybe doesn't fit what you expect, cause it takes more code to solve the problem.
Answer by VAIRIX for How to implement root route and get "index" to the same page

A possible solution that implies more than one line, is using scope to make it cleaner, you will have two extra lines of code, but I found it more readable:

scope :path => '/', :controller => :static_pages do
  get 'index' => :index, :as => 'index'
  get 'home' => :index, :as => 'home'
end

That way you make explicit which controller to use for all routes + the path (first part of it).

Answer by VAIRIX for How to implement root route and get "index" to the same page

A possible solution that implies more than one line, is using scope to make it cleaner, you will have two extra lines of code, but I found it more readable:

scope :path => '/', :controller => :static_pages do
  get 'index' => :index, :as => 'index'
  get 'home' => :index, :as => 'home'
end

That way you make explicit which controller to use for all routes + the path (first part of it).

Answer by VAIRIX for I don't really know what RSPEC assigns do, and my tests are failing

What you should expect from the assign after calling your controller, is to have the value that the controller sets to the instance variable. You could see it like using @category. So the category created with FactoryGirl is not equals to the one created by your controller (in this case seems your action is returning nil value in your instance variable)

Answer by VAIRIX for I don't know what RSpec assigns does, and my tests are failing

What you should expect from the assign after calling your controller, is to have the value that the controller sets to the instance variable. You could see it like using @category. So the category created with FactoryGirl is not equals to the one created by your controller (in this case seems your action is returning nil value in your instance variable)

Comment by VAIRIX on How to let the user create cron jobs in rails?
If you want to schedule a task every X period of time, and your user only sets when and the task (as you said), you could try doing it with delayedjob ` class.delay(run_at: 5.hours.from_now).method(param)` and call recursive in the method. Of course you will have some delay of excecution (even if the first thing in your method is calling the recursion). It should be some similar way to do it with Sidekiq (really don't know). Be careful with overlapping of tasks.
Comment by VAIRIX on How to let the user create cron jobs in rails?
If you want to schedule a task every X period of time, and your user only sets when and the task (as you said), you could try doing it with delayedjob ` class.delay(run_at: 5.hours.from_now).method(param)` and call recursive in the method. Of course you will have some delay of excecution (even if the first thing in your method is calling the recursion). It should be some similar way to do it with Sidekiq (really don't know). Be careful with overlapping of tasks.
Answer by VAIRIX for Select objects based on grandchild attribute with joins in ActiveRecord

This should be work!

Foo.joins(:bazs).where(bazs: {name: 'x'})
Answer by VAIRIX for Select objects based on grandchild attribute with joins in ActiveRecord

This should be work!

Foo.joins(:bazs).where(bazs: {name: 'x'})
Comment by VAIRIX on Use form to send ajax request to rails app
If you need more params from the view, just add them in the "data ajax attribute" like data:{ rows: val1, sort: val2 }
Comment by VAIRIX on Use form to send ajax request to rails app
If you need more params from the view, just add them in the "data ajax attribute" like data:{ rows: val1, sort: val2 }
Answer by VAIRIX for How can I display png data as an image inside in the browser?

One way to do this, is by doing the following: In the view

<img src="/get_img/tlotr">

That will make a request to the server, so in the routes.rb add

get '/get_img/:filename' => 'test#img'

In my case I have a TestController with an action call img like:

def img
  send_file( "/your_path/#{params[:filename]}.png",
    :disposition => 'inline',
    :type => 'image/png',
    :x_sendfile => true )
end

With this solution you hit the server one more time, but you don't have to send the data using the read method.

Answer by VAIRIX for How can I display png data as an image inside in the browser?

One way to do this, is by doing the following: In the view

<img src="/get_img/tlotr">

That will make a request to the server, so in the routes.rb add

get '/get_img/:filename' => 'test#img'

In my case I have a TestController with an action call img like:

def img
  send_file( "/your_path/#{params[:filename]}.png",
    :disposition => 'inline',
    :type => 'image/png',
    :x_sendfile => true )
end

With this solution you hit the server one more time, but you don't have to send the data using the read method.

Answer by VAIRIX for Use form to send ajax request to rails app

You can do something like that:

In your javascript file:

$('#my_button').click(function(){
  $.ajax({
    type:'GET',
    url: '/table',
    data:{ rows: $('#my_text_field').val() },
    success: function(data){
      $('#my_table_container').html(data);
    }
  });
});

In your controller:

def table
  render partial: 'table', locals: { rows: params[:rows] }
end

In your routes.rb:

match 'table' => 'your_controller#table'

And then in your partial (_partial.html.rb), you have to iterate over number of rows that you receive in the rows param.

Answer by VAIRIX for Use form to send ajax request to rails app

You can do something like that:

In your javascript file:

$('#my_button').click(function(){
  $.ajax({
    type:'GET',
    url: '/table',
    data:{ rows: $('#my_text_field').val() },
    success: function(data){
      $('#my_table_container').html(data);
    }
  });
});

In your controller:

def table
  render partial: 'table', locals: { rows: params[:rows] }
end

In your routes.rb:

match 'table' => 'your_controller#table'

And then in your partial (_partial.html.rb), you have to iterate over number of rows that you receive in the rows param.

Answer by VAIRIX for Helper for controller and views

Define it in the ApplicationController like:

class ApplicationController < ActionController::Base

  helper_method :paypal_url

  def paypal_url
    'https://www.paypal.com/cgi-bin/webscr'
  end

end

After that you'll be able to use the helper method from any view or controller.

Answer by VAIRIX for Helper for controller and views

Define it in the ApplicationController like:

class ApplicationController < ActionController::Base

  helper_method :paypal_url

  def paypal_url
    'https://www.paypal.com/cgi-bin/webscr'
  end

end

After that you'll be able to use the helper method from any view or controller.




What's going on?


How to contact us

Our Location

DireccionArismendi 1420 Of. 102 Telefono(+598) 2409 15 66 Mailinfo@vairix.com

Follow us


Want to contact us?