Thursday, April 30, 2015

iis 7 and rails

after struggling to get things running,
i finally found my best solution.

HttpPlatformHandler

If you are running iis 8, just use httpplatformhandler, it save you a lot of time. but you will need to get webmatrix running. but this is not supported on iis 7/7.5, a bummer :(

WebMatrix

so moving on to try microsoft web platform.
https://www.microsoft.com/web/webmatrix

also several issues,
webmatrix does not play well with proxy, ke-damn!

Some odd / weird results when trying to install webmatrix,
first, it requires iis express, and ive no idea why do it need it.
but after running install and it failed, we are still able to open the webmatrix installer options.
Just ignore the webmatrix installation issue.

webmatrix and proxy?

setting http proxy in environment does not help in one of my client case,
you might want to consider setting up this:
http://ntlmaps.sourceforge.net/ - works like a charm for me :)

Okay, please please please do not install helicon method. Their ruby and rails are outdated!
This will save you the hassle from installing old ruby 1.8 and 1.9 on your machines. And this may conflict with railsinstaller ruby.

So, what now? how do we run rails on /rails uri?
Yes, install Application Request Routing (ARR).
Inside webmatrix, search for arr, install it :)
After install, restart your iis manager (not refreshed if you have it opened while installing).

Okay, unless you want to setup entire host to proxy to another port, dont setup ARR on root level.

In my case, ive setup uri "/rails" to proxy over to my own rails instance.
Todo so, create a application "rails" under Default sites.
Then click into rails, and click on "Rewrite rules".
Then "Add rule" > "Reverse proxy"
Key in "127.0.0.1:3000" for server name,
After adding, double click on the rules, and ensure that you have similar configuration alike below. Notice the {R:1} appended as suffix of the rewrite url.

Setting up Rails + Ruby

to setup ruby, goto http://railsinstaller.org/en (thank god engine yard started something for us).
makesure to install with devkits and git and ssh.
it makes life much easier.
It will install to c:\RailsInstaller
all the paths should have been set for you, thank god :)

Then next, you might realize your gem install throws sslv3 certificate error with rubygems.org, another bummer. It turn out as of today 30th april 2015, certificate has been renewed on rubygems but it wasnt updated to the trusted repository of gems.
Follow here:
https://gist.github.com/luislavena/f064211759ee0f806c88

Since im using 2.1.5, ive followed to 2.0.15 instruction (not sure why the 2.0).
https://github.com/rubygems/rubygems/releases/tag/v2.0.15

Download the .gem, and runs:
gem install --local rubygems-update-2.0.15.gem
update_rubygems --no-ri --no-rdoc

you may run:
gem update (to test if it works)

You will realize latest rails is already installed by railsinstaller.
Create a new app to try
c:\Sites\rails new app1

then create a startup file (this is using webrick, best to replace using either puma or thin)
@echo off
set RAILS_ENV=production
set RAILS_RELATIVE_URL_ROOT=/rails
set SECRET_KEY_BASE=yoursecretkeyshere
rails s

and edit config.ru
and change `run Rails.application` to:
---------
map "/rails" do
  run Rails.application
end

map "/" do
  run Rails.application
end
---------

Notice the uri rails is used to indicated a uri so that all proxy over from iis can be used with this uri.

Installing Mysql2 gem

ensure your mysql2 gem is 0.3.18 or later

goto:
https://dev.mysql.com/downloads/connector/c/
install the connector of your platform and 32/64bits (install the installer if you want to use path below)

next, run:
path to connector: C:\Program Files\MySQL\MySQL Connector C #version
example: v6.1
gem install mysql2 --platform=ruby -- '--with-mysql-dir="C:\Program Files\MySQL\MySQL Connector C 6.1"'

Gems requirements on windows

Due to bugs and issues on windows, these are the min require versions of gem if you need to use them on windows:

gem 'eventmachine', '>=1.0.7'
gem 'bcrypt', '>= 3.1.10'
gem 'mysql2', '>=0.3.18'





Thursday, April 16, 2015

solr and pint

solr 5 no longer support p prefixed fieldtype,
therefore:
pint, pstring, pdate, etc... no longer supported.

solr query rows did not return all results

solr by default allows query
*:* and x=1

but it is not suppose to make sense if you are adding condition,
*:* should not be added.
but solr allows to return all results to match x=1.

but when use with edismax,
the results seems to return strange behaviour as it does not return all rows.
therefore, removing *:* does the tricks in use_dis_max = true is used.