Forum: IronRuby Updated Rails instructions

Posted by Jimmy Schementi (Guest)
on 2010-01-15 01:54
(Received via mailing list)
All,

http://ironruby.net/Documentation/Rails 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

2. Add the following to the top of your app's config/environment.rb:

require 'rubygems'
require 'ironruby_sqlserver'

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

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

4. 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
Posted by Ryan Riley (Guest)
on 2010-01-15 16:43
(Received via mailing list)
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 Riley

Email: ryan.riley@panesofglass.org
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 Schementi <
Posted by Ryan Riley (Guest)
on 2010-01-20 05:48
(Received via mailing list)
_______________________________________________
Ironruby-core mailing list
Ironruby-core@rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core
Posted by Ryan Riley (Guest)
on 2010-01-20 05:52
(Received via mailing list)
_______________________________________________
Ironruby-core mailing list
Ironruby-core@rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core
Posted by Ivan Porto carrero (casualjim)
on 2010-01-20 08:29
(Received via mailing list)
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 Carrero
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)
Posted by Jimmy Schementi (Guest)
on 2010-01-20 10:26
(Received via mailing list)
_______________________________________________
Ironruby-core mailing list
Ironruby-core@rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core
Posted by Ryan Riley (Guest)
on 2010-01-20 14:08
(Received via mailing list)
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. :) 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 Schementi 
<Jimmy.Schementi@microsoft.com
Posted by Ryan Riley (Guest)
on 2010-01-20 20:10
(Received via mailing list)
_______________________________________________
Ironruby-core mailing list
Ironruby-core@rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core
Posted by Sam Clopton (samsinite)
on 2010-01-20 21:49
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 Schementi wrote:
> All,
> 
> http://ironruby.net/Documentation/Rails 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
> 
> 2. Add the following to the top of your app's config/environment.rb:
> 
> require 'rubygems'
> require 'ironruby_sqlserver'
> 
> 3. Connect to SQLServer in config/database.yml:
> 
> development:
>   mode: ADONET
>   adapter: sqlserver
>   host: YOURMACHINENAME\SQLEXPRESS
>   database: app123_development
>   integrated_security: true
> 
> 4. 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
Posted by Jimmy Schementi (Guest)
on 2010-01-20 23:23
(Received via mailing list)
> (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
Posted by Sam Clopton (samsinite)
on 2010-01-22 23:31
> 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
Posted by Sam Clopton (samsinite)
on 2010-01-22 23:38
> 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"}
  User Load (0.0ms)   SELECT TOP 1 * FROM [users] 
WHERE ([users].[id] = '1') 
  EXECUTE (15.6ms)   BEGIN TRANSACTION
  Company Create (46.9ms)   INSERT INTO [companies] 
([name], [comments]) VALUES('hmmmjjj...', 'test')
  SQL (0.0ms)   SELECT SCOPE_IDENTITY() AS Ident
  EXECUTE (0.0ms)   COMMIT TRANSACTION
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]
Posted by Sam Clopton (samsinite)
on 2010-01-26 00:05
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"}
>   User Load (0.0ms)   SELECT TOP 1 * FROM [users] 
> WHERE ([users].[id] = '1') 
>   EXECUTE (15.6ms)   BEGIN TRANSACTION
>   Company Create (46.9ms)   INSERT INTO [companies] 
> ([name], [comments]) VALUES('hmmmjjj...', 'test')
>   SQL (0.0ms)   SELECT SCOPE_IDENTITY() AS Ident
>   EXECUTE (0.0ms)   COMMIT TRANSACTION
> 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
Posted by Jimmy Schementi (Guest)
on 2010-01-26 10:06
(Received via mailing list)
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
Posted by Ivan Porto carrero (casualjim)
on 2010-01-26 10:09
(Received via mailing list)
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 Carrero
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 Schementi <
Posted by Shri Borde (Guest)
on 2010-01-26 19:50
(Received via mailing list)
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 Carrero [mailto:ivan@flanders.co.nz]
Sent: Tuesday, January 26, 2010 1:09 AM
To: Jimmy Schementi
Cc: ironruby-core@rubyforge.org; Shri Borde
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 Carrero
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 Schementi 
<Jimmy.Schementi@microsoft.com<mailto:Jimmy.Schementi@microsoft.com>> 
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
Posted by Sam Clopton (samsinite)
on 2010-01-26 23:18
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 Carrero
> 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 Schementi <
Posted by Jimmy Schementi (Guest)
on 2010-01-29 01:31
(Received via mailing list)
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
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.