如何更改Rails 4中的按钮文本?

时间:2015-12-01 13:58:01

标签: ruby-on-rails ruby ruby-on-rails-4

如何更改Ruby on Rails中提交按钮的文本?我尝试过添加标签方法,但它不会起作用。

/ _ form.html.erb

  <div class="form-group">
    <%= f.submit class: "btn btn-primary" , label: "Click Here"%>
  </div>

2 个答案:

答案 0 :(得分:6)

而不是使用标签

import sys

charisma = 1
strength = 1
intelligence = 1
agility = 1
courage = 1
playerDamage = 20
magic = 0
playerHealth = 100

def orcCombat(playerHealth, playerDamage):


    orcHealth = 60

    while orcHealth > 0:
        if playerHealth > 10:
            print "You swing your sword at the orc!, He loses", playerDamage, "health!"
            playerHealth = playerHealth - 10
            orcHealth = orcHealth - playerDamage
        elif playerHealth == 10:
            print "The Orc swings a deadly fist and kills you!"
            print "Game Over"
        else:
            print "The Orc has killed you"
            print "Game Over"
            sys.exit()


    if orcHealth <= 0:
        print "You killed the Orc!"
        print "+1 Strength"
        print "HP = ", playerHealth
        global strength 
        strength = strength + 1
    return "press enter to continue"

orcCombat(playerHealth, playerDamage)
print strength
print playerHealth

答案 1 :(得分:3)

您可以提供自定义按钮名称,如: -

<%= f.submit 'custom_btn_name', class: "btn btn-primary" %>