mercredi 2 mars 2016

Rails - How to query using the string

I want to show the list of builds as follows

AppName     bundle
ABCD        test_1.3.5.0_AdHoc_69bd343d_v3.5_Omniture.ipa
ABCD        test_1.3.5.0_Store_69bd343d_v3.5_Omniture.ipa
DAA         test_1.3.4.0_AdHoc_69bd343d_v3.5_Omniture.ipa
DAA         test_1.3.4.0_Store_69bd343d_v3.5_Omniture.ipa

Builds table

id:integer appname:string bundle:string created_at:datetime

Build table data

+-----+--------------+----------------------------------------------------------------------------------+
| id  | app_name | bundle                                                                           |
+-----+--------------+----------------------------------------------------------------------------------+
|  36 |          ABCD | test_1.3.5.0_AdHoc_69bd343d_v3.5_Omniture.ipa                         |
|  37 |          DAA | test_AdHoc_69bd343d_v3.5_iture.ipa                            |
|  38 |          ABCD | test_1.3.5.0_Store_69bd343d_v3.5_mniture.ipa                         |
|  39 |          DAA | test_1.3.5.0_Store_69bd343d_v3.5_Omniture.ipa                         |

How should i achieve this ? Any idea ?

mardi 1 mars 2016

IN Query by using List of Object in Rails

I am new to rails , I try to make a Query lets suppose.

Table1(id,subjectId)
Table2(id,subjectId)

Now I have list of Table2 Object in a Object. And now I want to find all those objects from Table1 whose subject id in matches in List of table2 Object . Something like IN Query of Postgres

Rails 3.2 model validations and I18n

I got this error after add vlidation.

NoMethodError (undefined method `i18n_key' for "question":String):

My model:

class Question < ActiveRecord::Base

  validates_format_of :text, :without => /http:\/\//i, :on => :create, :allow_blank => false, :message => I18n.t('https_only')
...
end

config/locales/en.yml:

  en:

  https_only: 'Sorry, only https links allowed.'

Sabre Dev Studio API call by ruby

I'm trying to take hotels details from sabre dev studio in my app and I'm using gem 'sabre_dev_studio' but I can't understand how and which url I have to hit (APIs) for the hotel details. I'm using like this :

SabreDevStudio.configure do |c|
    c.client_id     = 'V1:kiifsurie29jj:KITPUI:DFR'
    c.client_secret = 'wiurRTs'
    c.uri           = 'http://ift.tt/1IvhrNK'
  end
  token = SabreDevStudio::Base.get_access_token
  themes = SabreDevStudio::Base.get('/v1/shop/themes')

this is working and give me proper response but for hotels I'm not getting which url are for apies.

uninitialized constant PackagesController::RiCal

I am getting error while trying to create ics file please review my code whats wrong with this:

uninitialized constant PackagesController::RiCal

Do I need to include or something else?

def i_cal
  pack = Administration::MerchantPackage.find(params[:id])
  loc = pack.offering.merchant.address.to_s + pack.offering.merchant.city.to_s
 cal = RiCal.Calendar do
   event do
     description pack.subtitle
     dtstart DateTime.parse(pack.start_date.strftime('%m/%d/%Y %H:%M:%S'))
     dtend DateTime.parse(pack.end_date.strftime('%m/%d/%Y %H:%M:%S'))
     location loc
     add_attendee current_user.email rescue ''
     alarm do
       description "Segment 51"
     end
   end
 end

When I try ::RiCal.Calendar it give me error:

uninitialized constant RiCal

Sidekiq is not successfully reporting errors to rollbar?

I got an application using rollbar and sidekiq and for some reason all errors occuring in sidekiq (in the logs where rollbar URLs are logged) are not posted. Whenever I try to open one of the items, I get:

UUID not found. It may still be processing. Hit refresh?

rollbar and sidekiq are default installations so if any info is needed, please let me know.

gem install nokogiri-1.6.6.2.gem failing

With 'bundle install' nokogiri gem file installing, but gem install nokogiri-1.6.6.2.gem failing with below error in centos 6.6. i installed libxml2, libxslt libs also.

Building native extensions. This could take a while... ERROR: Error installing nokogiri-1.6.6.2.gem: ERROR: Failed to build gem native extension.

/usr/bin/ruby -r ./siteconf20160301-19713-3tkoho.rb extconf.rb

checking if the C compiler accepts ... yes Building nokogiri using packaged libraries. checking for gzdopen() in -lz... yes checking for iconv... yes


IMPORTANT NOTICE:

Building Nokogiri with a packaged version of libxml2-2.9.2 with the following patches applied: - 0001-Revert-Missing-initialization-for-the-catalog-module.patch - 0002-Fix-missing-entities-after-CVE-2014-3660-fix.patch

Team Nokogiri will keep on doing their best to provide security updates in a timely manner, but if this is a concern for you and want to use the system library instead; abort this installation process and reinstall nokogiri as follows:

gem install nokogiri -- --use-system-libraries
    [--with-xml2-config=/path/to/xml2-config]
    [--with-xslt-config=/path/to/xslt-config]

If you are using Bundler, tell it to use the option:

bundle config build.nokogiri --use-system-libraries
bundle install

Note, however, that nokogiri is not fully compatible with arbitrary versions of libxml2 provided by OS/package vendors.


Extracting libxml2-2.9.2.tar.gz into tmp/x86_64-redhat-linux-gnu/ports/libxml2/2.9.2... OK Running patch with /usr/lib64/ruby/gems/2.2.0/gems/nokogiri-1.6.6.2/ports/patches/libxml2/0001-Revert-Missing-initialization-for-the-catalog-module.patch... Running 'patch' for libxml2 2.9.2... ERROR, review '/usr/lib64/ruby/gems/2.2.0/gems/nokogiri-1.6.6.2/ext/nokogiri/tmp/x86_64-redhat-linux-gnu/ports/libxml2/2.9.2/patch.log' to see what happened. * extconf.rb failed * Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options.

Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib64 --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/usr/bin/$(RUBY_BASE_NAME) --help --clean --use-system-libraries --enable-static --disable-static --with-zlib-dir --without-zlib-dir --with-zlib-include --without-zlib-include=${zlib-dir}/include --with-zlib-lib --without-zlib-lib=${zlib-dir}/lib64 --enable-cross-build --disable-cross-build /usr/lib64/ruby/gems/2.2.0/gems/mini_portile-0.6.2/lib/mini_portile.rb:279:in block in execute': Failed to complete patch task (RuntimeError) from /usr/lib64/ruby/gems/2.2.0/gems/mini_portile-0.6.2/lib/mini_portile.rb:271:inchdir' from /usr/lib64/ruby/gems/2.2.0/gems/mini_portile-0.6.2/lib/mini_portile.rb:271:in execute' from extconf.rb:311:inblock in patch' from extconf.rb:308:in each' from extconf.rb:308:inpatch' from /usr/lib64/ruby/gems/2.2.0/gems/mini_portile-0.6.2/lib/mini_portile.rb:108:in cook' from extconf.rb:278:inblock in process_recipe' from extconf.rb:177:in tap' from extconf.rb:177:inprocess_recipe' from extconf.rb:475:in `'

extconf failed, exit code 1

Gem files will remain installed in /usr/lib64/ruby/gems/2.2.0/gems/nokogiri-1.6.6.2 for inspection. Results logged to /usr/lib64/ruby/gems/2.2.0/extensions/x86_64-linux/2.2.0/nokogiri-1.6.6.2/gem_make.out [root@hh-rcs-push1 gemfiles]#