GitHub activity

@vairix-garbeletche
Dec 13, 2017
@vairix-garbeletche
Dec 13, 2017
search fix #21

What fix bug in search responsive

+6 -0
@vairix-garbeletche
Dec 13, 2017
search fix #21

What fix bug in search responsive

+6 -0
@vairix-garbeletche
vairix-garbeletche pushed to test in IntendenciaMontevideo/consul
  • @vairix-garbeletche e1c4dce
    Feature/v2 new style (#20)
Dec 13, 2017
@vairix-garbeletche
Dec 13, 2017
Feature/v2 new style #20

Where in the views What changes layouts and style and fonts

+1,035 -28
@vairix-garbeletche
Dec 13, 2017
@vairix-garbeletche
Dec 13, 2017
@vairix-garbeletche
Dec 13, 2017
Feature/v2 new style #20

Where in the views What changes layouts and style and fonts

+1,039 -44
@vairix-garbeletche
vairix-garbeletche pushed to test in IntendenciaMontevideo/consul
  • @vairix-garbeletche 1f2b716
    add custum page faq (#19)
Dec 8, 2017
@vairix-garbeletche
Dec 8, 2017
add custum page faq #19

Where add faq

+58 -0
@vairix-garbeletche
Dec 8, 2017
add custum page faq #19

Where add faq

+58 -0
@vairix-garbeletche
vairix-garbeletche pushed to test in IntendenciaMontevideo/consul
  • @vairix-garbeletche 25bf2d5
    Adds param to allow servers clock drifts (#18)
Dec 8, 2017
@vairix-garbeletche
Dec 8, 2017
Adds param to allow servers clock drifts #18

Where add alowed clock drift

+1 -0
@vairix-garbeletche
Dec 8, 2017
Adds param to allow servers clock drifts #18

Where add alowed clock drift

+1 -0
@vairix-garbeletche
Dec 7, 2017
@vairix-garbeletche
Dec 7, 2017
@vairix-garbeletche
Dec 7, 2017
change text #17

What Creare task with pages, and changes other text

+29 -5
@vairix-garbeletche
Dec 7, 2017
change text #17

What Creare task with pages, and changes other text

+29 -5
@vairix-garbeletche
Dec 7, 2017
@vairix-garbeletche
Dec 7, 2017
Change text #16

What Change text in legislation, process, nav bar, and home

+193 -37
@vairix-garbeletche
Dec 7, 2017
Change text #16

What Change text in legislation, process, nav bar, and home

+193 -37
@vairix-garbeletche
Dec 7, 2017
@vairix-garbeletche
vairix-garbeletche pushed to test in IntendenciaMontevideo/consul
  • @vairix-garbeletche d3603c7
    Adds session index to saml logout (#15)
Dec 5, 2017
@vairix-garbeletche
Dec 5, 2017
Adds session index to saml logout #15

resolve error logout session with saml

+6 -3
@vairix-garbeletche
Dec 5, 2017
Adds session index to saml logout #15

resolve error logout session with saml

+6 -3
@vairix-garbeletche
vairix-garbeletche pushed to test in IntendenciaMontevideo/consul
  • @vairix-garbeletche 58e4176
    add text requested by client (#14)
Dec 5, 2017
@vairix-garbeletche
Dec 5, 2017
add text requested by client #14

What Change text request by client

+324 -2
@vairix-garbeletche
Dec 5, 2017
@vairix-garbeletche
Dec 5, 2017
add text requested by client #14

What Change text request by client

+325 -2
@vairix-garbeletche
Dec 5, 2017
+659 -4
@vairix-garbeletche
vairix-garbeletche pushed to test in IntendenciaMontevideo/consul
  • @vairix-garbeletche 543e849
    change finnd username check validation data (#12)
Dec 5, 2017
@vairix-garbeletche
Dec 5, 2017
change finnd username check validation data #12

change find username check validation data, username to uid

+2 -2
@vairix-garbeletche
Dec 5, 2017
change finnd username check validation data #12

change find username check validation data, username to uid

+2 -2
@vairix-garbeletche
vairix-garbeletche pushed to test in IntendenciaMontevideo/consul
  • @vairix-garbeletche e892df8
    add last_name_2, add verified to connect saml with correct attr (#11)
Dec 5, 2017
@vairix-garbeletche
Dec 5, 2017
add last_name_2, add verified to connect saml with correct attr #11

Where user.rb, verification.rb, omniauth.rb What add last_name_2, add verified to connect saml with correct attr

+31 -10
@vairix-garbeletche
Dec 5, 2017
add last_name_2, add verified to connect saml with correct attr #11

Where user.rb, verification.rb, omniauth.rb What add last_name_2, add verified to connect saml with correct attr

+31 -10
@vairix-garbeletche
Dec 4, 2017
@vairix-garbeletche
vairix-garbeletche pushed to feature/authenticate_saml-change in IntendenciaMontevideo/consul
Dec 4, 2017
@vairix-garbeletche
Dec 4, 2017
@vairix-garbeletche
Dec 4, 2017
@vairix-garbeletche
vairix-garbeletche pushed to feature/authenticate_saml-change in IntendenciaMontevideo/consul
feature/authenticate_saml-change is now a404821
Dec 4, 2017
@vairix-garbeletche
vairix-garbeletche pushed to test in IntendenciaMontevideo/consul
  • @vairix-garbeletche 65ab0b0
    Feature/authenticate saml change (#8)
Dec 4, 2017
@vairix-garbeletche
Dec 4, 2017
Feature/authenticate saml change #8

What Whats the objective of this changes ? Create authentication with saml omniauth.

+334 -34
@vairix-garbeletche
Dec 4, 2017
@vairix-garbeletche
Dec 4, 2017
@vairix-garbeletche
Dec 4, 2017
Feature/authenticate saml change #8

What Whats the objective of this changes ? Create authentication with saml omniauth.

+314 -34
@vairix-garbeletche
vairix-garbeletche pushed to feature/authenticate_saml-change in IntendenciaMontevideo/consul
  • @vairix-garbeletche 2dbafdd
    add user verified with saml omniauth data
Dec 3, 2017
@vairix-garbeletche
vairix-garbeletche pushed to feature/authenticate_saml-change in IntendenciaMontevideo/consul
  • @vairix-garbeletche 5b86b54
    Adds saml response fields to user model and modifies users creation
Dec 1, 2017
@vairix-garbeletche
vairix-garbeletche pushed to feature/authenticate_saml-change in IntendenciaMontevideo/consul
  • @vairix-garbeletche 04b3a25
    change config onmiauth setteing embed_sign
Nov 30, 2017
@vairix-garbeletche
vairix-garbeletche pushed to feature/authenticate_saml-change in IntendenciaMontevideo/consul
  • @vairix-garbeletche 73e603b
    Adds attribute statements configuration to saml
Nov 30, 2017
@vairix-garbeletche
vairix-garbeletche pushed to feature/authenticate_saml-change in IntendenciaMontevideo/consul
Nov 30, 2017
@vairix-garbeletche
vairix-garbeletche pushed to feature/authenticate_saml in IntendenciaMontevideo/consul
  • @vairix-garbeletche 6caf6e7
    Fixes issuer and idp_entity_id settings for saml
Nov 29, 2017
@vairix-garbeletche
Nov 29, 2017
@vairix-garbeletche
Nov 27, 2017
@vairix-garbeletche
vairix-garbeletche deleted branch feature/authenticate_saml at IntendenciaMontevideo/consul
Nov 17, 2017
@vairix-garbeletche
vairix-garbeletche pushed to feature/authenticate_saml in IntendenciaMontevideo/consul
  • 5bcac44
    Adds configuration values and locales for saml omniauth
Nov 17, 2017
@vairix-garbeletche
vairix-garbeletche deleted branch feature/authenticate_saml at IntendenciaMontevideo/consul
Nov 17, 2017
@vairix-garbeletche
vairix-garbeletche pushed to test in IntendenciaMontevideo/consul
Nov 3, 2017
@vairix-garbeletche
Nov 3, 2017
disabled feature proposals #7

Where Related Issue: #1886 What Allow the admins to enable or disable the 'Proposals' feature How Modified seeds.rb and dev_seeds.rb to enable the …

+70 -18
@vairix-garbeletche
Nov 3, 2017
disabled feature proposals #7

Where Related Issue: #1886 What Allow the admins to enable or disable the 'Proposals' feature How Modified seeds.rb and dev_seeds.rb to enable the …

+70 -18
@vairix-garbeletche
vairix-garbeletche pushed to test in IntendenciaMontevideo/consul
Nov 3, 2017
@vairix-garbeletche
Nov 3, 2017
@vairix-garbeletche
vairix-garbeletche pushed to test in IntendenciaMontevideo/consul
Oct 31, 2017
@vairix-garbeletche
Oct 31, 2017
change initial config access #6

What change variable configuration

+1 -1
@vairix-garbeletche
Oct 31, 2017
change initial config access #6

What change variable configuration

+1 -1
@vairix-garbeletche
vairix-garbeletche pushed to feature/rake_task in IntendenciaMontevideo/consul
  • @vairix-garbeletche 95bb222
    change initial config access
Oct 31, 2017
@vairix-garbeletche
vairix-garbeletche pushed to test in IntendenciaMontevideo/consul
Oct 31, 2017
@vairix-garbeletche
Oct 31, 2017
@vairix-garbeletche
Oct 31, 2017
add task to initial setup #5

Where in rake task What config external login and modules visible

+18 -0


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?