Updated Rails instructions

All,

IronRuby.net / has been updated to show
instructions for running Rails 2.3.5 on IronRuby, including using the
official activerecord-sqlserver-adapter (v2.3). Thanks to Ivan for his
work on ironruby-dbi!

The steps are extrememly simple now. Assuming you have IronRuby
installed and a Rails app you’d like to run on IronRuby:

  1. Install Rake, Rails, and IronRuby SQLServer

igem install rake rails ironruby-sqlserver

  1. Add the following to the top of your app’s config/environment.rb:

require ‘rubygems’
require ‘ironruby_sqlserver’

  1. Connect to SQLServer in config/database.yml:

development:
mode: ADONET
adapter: sqlserver
host: YOURMACHINENAME\SQLEXPRESS
database: app123_development
integrated_security: true

  1. Migrate the database and start the server:

irake db:migrate
ir script\server

And that’s it! The documentation link above also has a walk through
setting up IronRuby, Rails, and SQLServer, and shows a basic Rails
“scaffold” running.

Coming soon are updated instructions for running rack-based web
applications in IIS on IronRuby.

Let me know if you have any questions,
~Jimmy

That’s terrific, Jimmy! Thanks! Jim mentioned that the ‘i’ prefix might
be
going away soon, but I noticed that you are still using the ‘i’-prefixed
versions of commands. What’s the timeline?

Cheers!

Ryan R.

Email: [email protected]
LinkedIn: http://www.linkedin.com/in/ryanriley
Blog: http://wizardsofsmart.net/
Twitter: @panesofglass
Website: http://panesofglass.org/

On Thu, Jan 14, 2010 at 6:48 PM, Jimmy S. <


Ironruby-core mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core

copying text from console 2. Copy is broken AFAICT.
Where do we submit a request to microsoft to finally include a console
that
allows you to copy paste with a keyboard shortcut from a console window,
tabs would be nice too.
I’ve wanted to get that for 15 years now.

right click the console window and select view > console window

That gives you the cmd window and you can use mark,…

Then to your rails problem. Does your database exist?

For item 2. Does anything show up in log/develpment.log?

Met vriendelijke groeten - Best regards - Salutations
Ivan Porto C.
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)


Ironruby-core mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core


Ironruby-core mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core


Ironruby-core mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core

Bug noticed:
Only with the new adapter (used igem install …), only when I create a
new row, the redirect below adds two 0’s to the end of the new rows id
(I.E. id = 56, it will try to show 5600). Switched back to the old
adapter (at work) for now.

code:
@company = Company.new(params[:company])
if @company.save
flash[:notice] = “Successfully created company.”
redirect_to company_path(@company)
else

Jimmy S. wrote:

All,

IronRuby.net / has been updated to show
instructions for running Rails 2.3.5 on IronRuby, including using the
official activerecord-sqlserver-adapter (v2.3). Thanks to Ivan for his
work on ironruby-dbi!

The steps are extrememly simple now. Assuming you have IronRuby
installed and a Rails app you’d like to run on IronRuby:

  1. Install Rake, Rails, and IronRuby SQLServer

igem install rake rails ironruby-sqlserver

  1. Add the following to the top of your app’s config/environment.rb:

require ‘rubygems’
require ‘ironruby_sqlserver’

  1. Connect to SQLServer in config/database.yml:

development:
mode: ADONET
adapter: sqlserver
host: YOURMACHINENAME\SQLEXPRESS
database: app123_development
integrated_security: true

  1. Migrate the database and start the server:

irake db:migrate
ir script\server

And that’s it! The documentation link above also has a walk through
setting up IronRuby, Rails, and SQLServer, and shows a basic Rails
“scaffold” running.

Coming soon are updated instructions for running rack-based web
applications in IIS on IronRuby.

Let me know if you have any questions,
~Jimmy

(I.E. id = 56, it will try to show 5600). Switched back to the old
adapter (at work) for now.

code:
@company = Company.new(params[:company])
if @company.save
flash[:notice] = “Successfully created company.”
redirect_to company_path(@company)
else

I’m not seeing this; the scaffolding example at the link below does the
same thing, and redirects fine with the new adapter (a Post created with
the id “4” will redirect to “/posts/4”):

@post = Post.new(params[:post])
if @post.save
flash[:notice] = ‘Post was successfully created.’
redirect_to(@post)
else
render :action => “new”
end

Can you possibly send more information with the old adapter? I’d like
these lines added right after @company.save succeeds (inside the “if”
statement), and then could you send the output?

p params
p @company
p company_path(@company)

~Jimmy

I’m not seeing this; the scaffolding example at the link below does the
same thing, and redirects fine with the new adapter (a Post created with
the id “4” will redirect to “/posts/4”):

@post = Post.new(params[:post])
if @post.save
flash[:notice] = ‘Post was successfully created.’
redirect_to(@post)
else
render :action => “new”
end

Can you possibly send more information with the old adapter? I’d like
these lines added right after @company.save succeeds (inside the “if”
statement), and then could you send the output?

p params
p @company
p company_path(@company)

~Jimmy

Hopefully this helps:

authenticity_tokenmrfvGtPzabzzhhdx/NFuxMlM64Q50R0V3cQbOtpJjws=companynamehmmmjj…commentstestcommitSubmitcontrollercompaniesactioncreate
#Company:0x000ea44
/companies/268

I’m not seeing this; the scaffolding example at the link below does the
same thing, and redirects fine with the new adapter (a Post created with
the id “4” will redirect to “/posts/4”):

@post = Post.new(params[:post])
if @post.save
flash[:notice] = ‘Post was successfully created.’
redirect_to(@post)
else
render :action => “new”
end

Can you possibly send more information with the old adapter? I’d like
these lines added right after @company.save succeeds (inside the “if”
statement), and then could you send the output?

p params
p @company
p company_path(@company)

~Jimmy

Should have included this in the last post, but
here is both of the data with the new/old adapter:

*** New Adapter ***

Processing CompaniesController#create (for 127.0.0.1 at 2010-01-22
14:33:19) [POST]
Parameters:
{“authenticity_token”=>“mrfvGtPzabzzhhdx/NFuxMlM64Q50R0V3cQbOtpJjws=”,
“company”=>{“name”=>“hmmmjjj…”, “comments”=>“test”},
“commit”=>“Submit”, “controller”=>“companies”, “action”=>“create”}
e[4;36;1mUser Load (0.0ms)e[0m e[0;1mSELECT TOP 1 * FROM [users]
WHERE ([users].[id] = ‘1’) e[0m
e[4;35;1mEXECUTE (15.6ms)e[0m e[0mBEGIN TRANSACTIONe[0m
e[4;36;1mCompany Create (46.9ms)e[0m e[0;1mINSERT INTO [companies]
([name], [comments]) VALUES(‘hmmmjjj…’, ‘test’)e[0m
e[4;35;1mSQL (0.0ms)e[0m e[0mSELECT SCOPE_IDENTITY() AS Idente[0m
e[4;36;1mEXECUTE (0.0ms)e[0m e[0;1mCOMMIT TRANSACTIONe[0m
authenticity_tokenmrfvGtPzabzzhhdx/NFuxMlM64Q50R0V3cQbOtpJjws=companynamehmmmjjj…commentstestcommitSubmitcontrollercompaniesactioncreate
#Company:0x000263e
/companies/26900
Redirected to http://127.0.0.1:3000/companies/26900

*** Old Adapter ***

Processing CompaniesController#create (for 127.0.0.1 at 2010-01-22
14:30:02) [POST]
Parameters:
{“authenticity_token”=>“mrfvGtPzabzzhhdx/NFuxMlM64Q50R0V3cQbOtpJjws=”,
“company”=>{“name”=>“hmmmjj…”, “comments”=>“test”},
“commit”=>“Submit”, “controller”=>“companies”, “action”=>“create”}
authenticity_tokenmrfvGtPzabzzhhdx/NFuxMlM64Q50R0V3cQbOtpJjws=companynamehmmmjj…commentstestcommitSubmitcontrollercompaniesactioncreate
#Company:0x000ea44
/companies/268
Redirected to http://127.0.0.1:3000/companies/268
Completed in 1922ms (DB: 0) | 302 Found [http://127.0.0.1/companies]

I did everything you noted below. I think I had already installed
ironruby-sqlserber, which is why I didn’t notice the adapter. In
answer to Ivan, I created my database but forgot to check the logs.
It’s been awhile since I used Rails and had db issues. :slight_smile: Sadly, the
log just tells me what trace tells me, which isn’t too surprising.

I have had problems with connection timeouts on this machine in the
past, but that was generally noticable in SSMS as well. I’ll try on
another machine and see where I land.

Thanks for the help!

Ryan

Sent from my iPhone

On Jan 20, 2010, at 3:24 AM, Jimmy S.
<[email protected]

I wanted to see “p @company” (equivalent of “puts @company.inspect”) to
see what fields it had, since ActiveRecord shows detailed view of the
object, including fields. Really I want to see whether the ID is “269”
or “26900”.

Ivan, does this issue seem at all familiar to you?

Sam, it’d be helpful if you could produce a small repro, just with
ActiveRecord alone, that shows the ID being appended with two zeros. I’d
suggest using script\console as it gives you an environment
preconfigured for ActiveRecord. If we have a targeted repo of the issue,
it’ll be easier to diagnose and fix. Ideally, you could just send me the
application zipped up, but at a minimum I’ll need the migration that
creates the table, the model file, and whatever other code reproduces
the error.

~Jimmy

I’m not seeing that issue atm but I’ll work on ironruby-sqlserver
tonight.
So if Sam wants to send me a repro I can also look at the cause for his
problem and hopefully fix it.

Met vriendelijke groeten - Best regards - Salutations
Ivan Porto C.
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)

On Tue, Jan 26, 2010 at 10:06 AM, Jimmy S. <

Sam Clopton wrote:

Processing CompaniesController#create (for 127.0.0.1 at 2010-01-22
14:33:19) [POST]
Parameters:
{“authenticity_token”=>“mrfvGtPzabzzhhdx/NFuxMlM64Q50R0V3cQbOtpJjws=”,
“company”=>{“name”=>“hmmmjjj…”, “comments”=>“test”},
“commit”=>“Submit”, “controller”=>“companies”, “action”=>“create”}
e[4;36;1mUser Load (0.0ms)e[0m e[0;1mSELECT TOP 1 * FROM [users]
WHERE ([users].[id] = ‘1’) e[0m
e[4;35;1mEXECUTE (15.6ms)e[0m e[0mBEGIN TRANSACTIONe[0m
e[4;36;1mCompany Create (46.9ms)e[0m e[0;1mINSERT INTO [companies]
([name], [comments]) VALUES(‘hmmmjjj…’, ‘test’)e[0m
e[4;35;1mSQL (0.0ms)e[0m e[0mSELECT SCOPE_IDENTITY() AS Idente[0m
e[4;36;1mEXECUTE (0.0ms)e[0m e[0;1mCOMMIT TRANSACTIONe[0m
authenticity_tokenmrfvGtPzabzzhhdx/NFuxMlM64Q50R0V3cQbOtpJjws=companynamehmmmjjj…commentstestcommitSubmitcontrollercompaniesactioncreate
#Company:0x000263e
/companies/26900
Redirected to http://127.0.0.1:3000/companies/26900

*** Old Adapter ***

Processing CompaniesController#create (for 127.0.0.1 at 2010-01-22
14:30:02) [POST]
Parameters:
{“authenticity_token”=>“mrfvGtPzabzzhhdx/NFuxMlM64Q50R0V3cQbOtpJjws=”,
“company”=>{“name”=>“hmmmjj…”, “comments”=>“test”},
“commit”=>“Submit”, “controller”=>“companies”, “action”=>“create”}
authenticity_tokenmrfvGtPzabzzhhdx/NFuxMlM64Q50R0V3cQbOtpJjws=companynamehmmmjj…commentstestcommitSubmitcontrollercompaniesactioncreate
#Company:0x000ea44
/companies/268
Redirected to http://127.0.0.1:3000/companies/268
Completed in 1922ms (DB: 0) | 302 Found [http://127.0.0.1/companies]

Jimmy,

Do you have any suggestions or is there anything else I can do to help
pin down this problem?

Thanks,
Sam

The database has information that is FOUO. Even though to me it seems
that none of the source code has any of that information (why should
it), I don’t really want to send any of it other than snippets just to
protect myself. I should be able to put together a different case at
home that has the same problems as mine.

If the ActiveRecord unit tests noted above by Shri will work, let me
know.

Ivan Porto carrero wrote:

I’m not seeing that issue atm but I’ll work on ironruby-sqlserver
tonight.
So if Sam wants to send me a repro I can also look at the cause for his
problem and hopefully fix it.

Met vriendelijke groeten - Best regards - Salutations
Ivan Porto C.
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)

On Tue, Jan 26, 2010 at 10:06 AM, Jimmy S. <

The ActiveRecord unit tests do have failures where extra 0s are
appended. You can see it from the following disabled tags in
Merlin\Main\Languages\Ruby\Tests\Scripts\utr\active_record_tests.rb (its
not yet pushed to GIT).

disable InheritanceTest,
  # <#<VerySpecialClient id: 780, type: nil, ruby_type: 

“VerySpecialClient”, firm_id: nil, firm_name: nil, name: “veryspecial”,
client_of: nil, rating: 1>> expected but was
# <#<VerySpecialClient id: 78, type: nil, ruby_type:
“VerySpecialClient”, firm_id: nil, firm_name: nil, name: “veryspecial”,
client_of: nil, rating: 1>>.
#
# diff:
# - #<VerySpecialClient id: 780, type: nil, ruby_type:
“VerySpecialClient”,
:test_alt_complex_inheritance,

disable HasOneThroughAssociationsTest,
  # ActiveRecord::StatementInvalid: DBI::DatabaseError: Arithmetic 

overflow error converting expression to data type int.
# The statement has been terminated.: INSERT INTO [memberships]
([joined_on], [club_id], [member_id], [favourite], [type]) VALUES(NULL,
1054009214000000000, 102717546000000000, 0, ‘CurrentMembership’)
# abstract_adapter.rb:201:in log' # sqlserver_adapter.rb:839:in raw_execute’
# sqlserver_adapter.rb:403:in `execute’
:test_assigning_association_correctly_assigns_target,

From: Ivan Porto C. [mailto:[email protected]]
Sent: Tuesday, January 26, 2010 1:09 AM
To: Jimmy S.
Cc: [email protected]; Shri B.
Subject: Re: [Ironruby-core] Updated Rails instructions

I’m not seeing that issue atm but I’ll work on ironruby-sqlserver
tonight.
So if Sam wants to send me a repro I can also look at the cause for his
problem and hopefully fix it.

Met vriendelijke groeten - Best regards - Salutations
Ivan Porto C.
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)

On Tue, Jan 26, 2010 at 10:06 AM, Jimmy S.
<[email protected]mailto:[email protected]>
wrote:
I wanted to see “p @company” (equivalent of “puts @company.inspect”) to
see what fields it had, since ActiveRecord shows detailed view of the
object, including fields. Really I want to see whether the ID is “269”
or “26900”.

Ivan, does this issue seem at all familiar to you?

Sam, it’d be helpful if you could produce a small repro, just with
ActiveRecord alone, that shows the ID being appended with two zeros. I’d
suggest using script\console as it gives you an environment
preconfigured for ActiveRecord. If we have a targeted repo of the issue,
it’ll be easier to diagnose and fix. Ideally, you could just send me the
application zipped up, but at a minimum I’ll need the migration that
creates the table, the model file, and whatever other code reproduces
the error.

~Jimmy

I think they will work as a good enough repro. I’ll let you know when we
have a fix. Ivan, are you looking into this?

~Jimmy