Ruby on Rails Monday, July 25, 2016

Hi everyone. I faced with such problem:
My model Order accepts nested attributes for model Address. It belongs
to Address model and has shipping and billing address. I use nested
forms to update or create addresses and everything is fine but I need to
make an ability to mark checkobox 'use billing address for shipping' to
avoid user to fill shipping address form and just use the same data as
billing. So i can't understand how to do that. I receive attributes with
their proper ids from DB and I can't just tell 'If checkbox so
shipping_attributes = biling_attributes'. Here's my controller

def update
return redirect_to address_path if @order.update(order_params)
render :show
end

private


def init_order
@order = current_order
end

def order_params
params.require(:order).permit(shipping_address_attributes:
address_params,
billing_address_attributes:
address_params)
end

def address_params
%i(id first_name last_name street zip_code city phone country)
end

So I should write some condition in update action to perform this. But
how to do it most clearly???

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/6ddcdf201a1ea30512b8cb3f80da9388%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Using authentication and authorization, lock down your ActionCable
WebSockets so that messages are only sent and received to the intended
users.
https://www.driftingruby.com/episodes/actioncable-part-3-securing-your-websockets

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/f3925e31a008a93d1efe29e8f300ccd2%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On 25 July 2016 at 10:00, Deepak Sharma <deeky.sharma@gmail.com> wrote:
> On Mon, Jul 25, 2016 at 1:59 PM, Colin Law <clanlaw@gmail.com> wrote:
>> You have not made it clear exactly what the problem is. Which line in
>> the above is not doing what you expect?
>
> Problem is In below mentioned each statement part
>
> <% @student.comments.each do |comment| %>
> <li class="collection-item">
> <div>
>
> <%= comment.content %>
>
> </div>
> </li>
> <% end %>
>
>
> It's returning empty value, I checked it in database but nothing there.

Well if there is nothing in the database then why would you expect it
to show something in the view?

Colin

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLtkje%3DriZ2va4C877VAf8V2cjdTL%3Det_YgmZLMSK3G4JQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.