Project

General

Profile

Automating Forum Creation

Added by Matt Mencel almost 10 years ago

There is no forum API, so I've attempted to use the Mechanize gem to do the forum creation for me. Unfortunately, even though the code looks like it works, HTTP 200 from Redmine, no forum is getting created in Redmine. I've added an Issue to the Mechanize gem github page, but maybe the question would be better asked here.

https://github.com/sparklemotion/mechanize/issues/425

Anyone have any ideas why my code isn't working?

Matt

def create_forum(k, v)
  puts "#{k}: #{v}" 
  agent = Mechanize.new
  agent.log = Logger.new(STDOUT)
  agent.get('http://redmineserver/login')
  form = agent.page.forms.first
  form.username = 'USER'
  form.password = 'PASS'
  form.submit
  agent.get('http://redmineserver/projects/change/boards/new') do |page|
    page.form_with(action: '/projects/change/boards') do |form|
      form['board[name]'] = "#{k}: #{v}" 
      form['board[description]'] = 'ITG Forum'
      form['submit'] = 'Create'
    end.submit
  end
end