L
L
lavezzi12015-08-24 20:16:31
Ruby on Rails
lavezzi1, 2015-08-24 20:16:31

How to add different classes to blocks?

Hello!
Is it possible to make it so that in the final code, a certain class is added to the sender and receiver in order to style these blocks differently. Thank you.

.wrapper
  .container     
    - if @over_ten
      = link_to 'Show Previous', '?m=all'
    .ui.segment
      - @messages.each do |message|
        - if message.body
          - user = User.find(message.user_id)
          .item
            .content
              .header
                %strong= user.first_name
                = message.message_time
              .list
                .item
                  %i.right.triangle.icon
                  = message.body
    = form_for [@conversation, @message], html: {class: "ui reply form"} do |f|
      .field
        = f.text_area :body, class: "form-control"
      = f.text_field :user_id, value: current_user.id, type: "hidden"
      %div
        = f.submit "Add Reply", class: "ui blue labeled submit icon button"
      %div
        = link_to "Delete conversation", conversation_path(@conversation), :method => :delete, :data => { :confirm => 'Are you sure?' }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
thepry, 2015-08-24
@thepry

specific class to sender and receiver

The sender is message.user, and who is the recipient?
- @messages.each do |message|
- if message.body
- user = User.find(message.user_id)
Doing so is very bad.

S
Stanislav, 2015-08-25
@crackedmind

.item class=(condition ? 'sender' : 'recipient' )
The output will be

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question