Forum: JRuby Call Java with JRuby

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Cecchin D. (Guest)
on 2009-05-02 16:21
Hi,

I am a problem for my project at University....
the using:

JRuby => 1.8.6
Rails  => 2.3.2
Java => JDK 1.6 and MySql 5.06

The Call java in Jruby is correct:

* configuration the file jar
Open File Configuration/environment.rb

  Dir["#{RAILS_ROOT}/lib/**/*.jar"].each do |jarfile|
  require jarfile
  end

*** And i added in this file
  require 'rubygems'
  gem 'activerecord-jdbc-adapter'
  require 'jdbc_adapter'
  include Java

*** in the controller implements the costruct Java
import "java.post.PostInformation"
import "java.post.PostManagement"
class Post
  def attibute
     @title = post_info.setTitle(" ")
     @description = post_info.setDescription(" ")
   end

   def create
       @post_info = PostInformation.new
       @post_mgm = PostManagement.new
       post_mgm.addPost(attribute)
   end

In the model
class Post

  #Question:  define the methods for views, it's a correct???

  def title
   @post_info = PostInformation.new
  post_info.setTitle(" ")
  end

View
<h1>New post</h1>

<% form_tag :controller => 'posts', :active => 'create' do %>

  <p>
    <%= label_tag :title %><br />
    <%= text_field_tag :title   %>
  </p>

  <p>
    <%= label_tag :description %><br />
    <%= text_area_tag :description  %>
  </p>


  <p>
   <%= submit_tag 'Create' %>
  </p>
<% end %>


sorry for my English .... :P

Thanks
Daniel
This topic is locked and can not be replied to.