Sha256: 71a9168fad2fd56562cad89427295a706b853a39acc9e6c7c70a78e42bcc9810

Contents?: true

Size: 1.55 KB

Versions: 7

Compression:

Stored size: 1.55 KB

Contents

class WhowishWordController < ActionController::Base
  
  def css
    
    text = ""
    
    Dir[File.expand_path("../../../public/stylesheets/*.css", __FILE__)].each { |f| 
      text += IO.read(f)
      text += "\n\n"
    }
    
    response.headers["Content-Type"] = "text/css; charset=utf-8"
    render :text=>text
    
  end
  
  def js
 
    text = ""
    
    all_files = Dir[File.expand_path("../../../public/javascripts/*.js", __FILE__)]
    all_files.sort! { |a, b| a <=> b}
    
    all_files.each { |file|
      text += IO.read(file)
      text += "\n\n"
    }
    
    response.headers["Content-Type"] = "text/javascript; charset=utf-8"
    render :text=>text
    
  end
  
  def change_word

    entity = WhowishWordHtml.first(:conditions=>{:word_id => params[:word_id].strip})

    entity = WhowishWordHtml.new if !entity

    entity.word_id = params[:word_id].strip
    entity.content = params[:content].strip
    
    if !entity.save
      
      error_message = "WhowishWord fails to change the word you specified.<br/>" + \
                      "Possible causes:<br/>" + \
                      "- Someone else changed the word at the very same time<br/>" + \
                      "- Database connection failed<br/>" + \
                      "By all means, please try again.<br/>"
                      
      render :json=>{:ok=>false,:error_message=>error_message}
      
    end
    
    WhowishWord.add_or_set_word(entity.word_id, entity.content)
    
    render :json=>{:ok=>true}
  end
  
  
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
whowish_word-0.3.1 lib/whowish_word/rails/app/controllers/whowish_word_controller.rb
whowish_word-0.3.0 lib/whowish_word/rails/app/controllers/whowish_word_controller.rb
whowish_word-0.2.7 lib/whowish_word/rails/app/controllers/whowish_word_controller.rb
whowish_word-0.2.6 lib/whowish_word/rails/app/controllers/whowish_word_controller.rb
whowish_word-0.2.5 lib/whowish_word/rails/app/controllers/whowish_word_controller.rb
whowish_word-0.2.3 lib/whowish_word/rails/app/controllers/whowish_word_controller.rb
whowish_word-0.2.2 lib/whowish_word/rails/app/controllers/whowish_word_controller.rb