Re: [Rails] Get all site tree with Ruby

2015-05-12 Thread Роман Ярыгин
Yeah, thanks. I figured it out. Now I stuck with million other problems, but this is another theme =) среда, 13 мая 2015 г., 10:36:34 UTC+10 пользователь Scott Ribe написал: On May 12, 2015, at 5:21 PM, Роман Ярыгин 330...@gmail.com javascript: wrote: I stuck exactly on recursive

Re: [Rails] Get all site tree with Ruby

2015-05-12 Thread Роман Ярыгин
. On Tue, May 12, 2015 at 7:42 AM, Роман Ярыгин 330...@gmail.com javascript: wrote: Hello! I need to grab all site data with all tree structure. Every page have links to children pages. How to build site tree with Nokogiri? It must be recursive page visiting and scraping all directory links

[Rails] Get all site tree with Ruby

2015-05-11 Thread Роман Ярыгин
Hello! I need to grab all site data with all tree structure. Every page have links to children pages. How to build site tree with Nokogiri? It must be recursive page visiting and scraping all directory links, but I can't recognize full algorhytm. How to do that? P.S. And I don't need to Save

[Rails] Re: Rails, Mongoid-Ancestry: Exclude child nodes if parent node is not selected

2015-03-22 Thread Роман Ярыгин
Okay. Here is the solution In ApplicationController: before_filter do @main_menu = Page.where(active: true, show_in_main_menu: true).arrange(order: :position) def menu_ids(attributes, mids = []) attributes.map do |attribute, sub_attributes| if sub_attributes.empty?

[Rails] Rails, Mongoid-Ancestry: Exclude child nodes if parent node is not selected

2015-03-20 Thread Роман Ярыгин
Hello! Please help with trouble (I think it must be obvious solution) I have code for displaying main menu: @main_menu = Page.where(active: true).arrange(order: :position) It grabs all nodes with active parameter is set to true. But if the parent node for some children is set to

Re: [Rails] Rails, Mongoid-Ancestry: Exclude child nodes if parent node is not selected

2015-03-20 Thread Роман Ярыгин
This is the model: class Page include Mongoid::Document include Mongoid::Timestamps include Mongoid::Ancestry include Mongoid::Orderable has_ancestry orphan_strategy: :destroy orderable column: :position, base: 0 has_many :page_attachment_files field :name, type: String field

[Rails] Ransack: make filter Greater than 1

2014-03-06 Thread Роман Ярыгин
Hello. I have a check box in filter, that must filter all objects, where some field value is greater than 1. How to make predicate in Ransack? -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop

[Rails] Please help to DRY snippet

2014-02-24 Thread Роман Ярыгин
Hello. Please, help me to DRY this code snippet. The task is to print div content, but to print it in div, when i%17 ==0 and make it without div, when not. I guess that it maybe proc or lambda will help, but I never used it before. Or maybe it is some simpler method? #splitter -

[Rails] CanCan: How to define ability with some conditions

2014-02-16 Thread Роман Ярыгин
Hello everyone! I have code: if user.role == topmanager can :read, ActiveAdmin::Page, :name = Dashboard can :manage, Realty, agent: {agency_id: user.agency_id} ... And I want to add another condition, can :manage, Realty, agent: nil How to do it? Defining it two times gets

[Rails] Is Array constants in the model can be changed during runtime?

2014-02-03 Thread Роман Ярыгин
Hello everyone! I have strange problem. Here is the code: model: class ItServiceJob ActiveRecord::Base TYPES = [[Important, 0], [Not important, 1], [SERGEY, 2]] belongs_to :userend view (haml): %div{:role = main, :class = ui-content} - job_types = ItServiceJob::TYPES

[Rails] Re: Is Array constants in the model can be changed during runtime?

2014-02-03 Thread Роман Ярыгин
Thank you for the answers! Will try at work tomorrow! P.S. I just copy-paste formatted text from another forum =) -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an