Re: [Rails] data no same.

2016-10-17 Thread Colin Law
On 17 October 2016 at 01:51, kinoe -  wrote:

> try show me versi your code rails what your suggest. i was tried but
> failed.
>

You really should follow my previous advice to work right through
railstutorial.org, including doing all the exercises. That way you will
learn the basics of rails and not need to ask for help with simple problems.

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+unsubscr...@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%3D0gLvnG0FPTes0vjAUbLGTBvif39G53E0tr-Y8us2PiAhALQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] data no same.

2016-10-16 Thread kinoe -
try show me versi your code rails what your suggest. i was tried but failed.

-- 
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+unsubscr...@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/2a998b59-9fc4-4b27-bc6e-e6a087faf0c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] data no same.

2016-10-16 Thread nanaya
Hi,

On Sun, Oct 16, 2016, at 22:34, kinoe - wrote:
>  I'm assuming you want if
> @admin.save then a render or
> redirect afterwards.
> #correct,i assuming here i want input data to db with defference name.
> #means:if i have field name with value "cow" on db, i not want not have
> two "cow" name on table Box,because that i use @n as checker,are there
> name with 'cow'.'quotes'(i want make sign up with manual but here i
> assuming def create as login for my ask today).

What you're looking for is probably uniqueness check, either at model
level (validates_uniqueness_of) and/or database (unique index).

> if @n

Here, @n will always be true because you have:

> @n = Box.where(name: params[:name])

which always return trueish value even when there's no result. You need
either call `take` or use `find_by` instead or do it properly as I wrote
above.

> #i am using hp,i hope you understand that has give.
> (:-) my english less)
> 

Try learning English (for example, using https://id.duolingo.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+unsubscr...@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/1476625430.2663335.757473465.55CC4541%40webmail.messagingengine.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] data no same.

2016-10-16 Thread kinoe -
 I'm assuming you want if
@admin.save then a render or
redirect afterwards.
#correct,i assuming here i want input data to db with defference name.
#means:if i have field name with value "cow" on db, i not want not have two 
"cow" name on table Box,because that i use @n as checker,are there name with 
'cow'.'quotes'(i want make sign up with manual but here i assuming def create 
as login for my ask today).
Truely i have 2 controller
1.blog_
2.user_
for this action i assuming that  "def create" on user_ ,than back to my ask.
if @n
render 'new' #'new' method on user_
#why i using 'render'because for flash[:error] ex:sorry that name... & if not 
use than flash no function
else
@admin.save
redirect_to blog_index_path #this routes back to index
#why,because same i using flash
end
---
 Your else
condition should be render new.
#i war tried,but same too.
(:-) my english less)

-- 
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+unsubscr...@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/2d59ca45-9aee-4698-a1ff-5bf25e5b486a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] data no same.

2016-10-16 Thread kinoe -
 I'm assuming you want if
@admin.save then a render or
redirect afterwards.
#correct,i assuming here i want input data to db with defference name.
#means:if i have field name with value "cow" on db, i not want not have two 
"cow" name on table Box,because that i use @n as checker,are there name with 
'cow'.'quotes'(i want make sign up with manual but here i assuming def create 
as login for my ask today).
Truely i have 2 controller
1.blog_
2.user_
for this action i assuming that  "def create" on user_ ,than back to my ask.
if @n
render 'new' #'new' method on user_
#why i using 'render'because for flash[:error] ex:sorry that name...
else
@admin.save
redirect_to blog_index_path #this routes back to index
#why,because same i using flash
end
---
 Your else
condition should be render new.
#i was tried,but same too.
#i am using hp,i hope you understand that has give.
(:-) my english bad)

-- 
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+unsubscr...@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/c19eb54c-06d7-463f-9d8a-2ce889bb4b00%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] data no same.

2016-10-16 Thread kinoe -
 I'm assuming you want if
@admin.save then a render or
redirect afterwards.
#correct,i assuming here i want input data to db with defference name.
#means:if i have field name with value "cow" on db, i not want not have two 
"cow" name on table Box,because that i use @n as checker,are there name with 
'cow'.'quotes'(i want make sign up with manual but here i assuming def create 
as login for my ask today).
Truely i have 2 controller
1.blog_
2.user_
for this action i assuming that  "def create" on user_ ,than back to my ask.
if @n
render 'new' #'new' method on user_
#why i using 'render'because for flash[:error] ex:sorry that name...
else
@admin.save
redirect_to blog_index_path #this routes back to index
#why,because same i using flash
end
---
 Your else
condition should be render new.
#i war tried,but same too.
#i am using hp,i hope you understand that has give.
(:-) my english less)

-- 
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+unsubscr...@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/58d3ba5d-4a4b-4861-949a-5322b549e176%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] data no same.

2016-10-16 Thread James Jelinek
In this action you're saying if @n render new which will always render your new 
view in the controller namespace. Then your else is @admin.save

That's why it's not functioning. Depending on what you are trying to do I'm 
assuming you want if @admin.save then a render or redirect afterwards. Your 
else condition should be render new. 

If you can provide some more context and how this should behave I'll be happy 
to help further. 

Sent from my iPhone

> On Oct 16, 2016, at 5:36 AM, kinoe -  wrote:
> 
> controller.rb
> .
> def create
> @admin = Box.new(admin_params)
> @n = Box.where(name: params[:name])
> if @n
> render 'new'
> else
> @admin.save
> 
> end
> 
> no error but no function.so how suggest for if input so that data not same.
> 
> -- 
> 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+unsubscr...@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/5ec2acdb-e115-4975-81f9-00230c7fac0a%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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+unsubscr...@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/97C52DC3-7DD5-4B87-B7EC-0018FE5FAD63%40gmail.com.
For more options, visit https://groups.google.com/d/optout.