[Rails] Re: Has anyone setup Acts_as_Follower Gem Successfully?

2016-01-22 Thread David Williams
I got it working, but now, I just have to add AJAX.

  <% if user_signed_in? %>
  <% if current_user.following?(@user) %>
  <%= link_to "Unfollow", unfollow_user_path(@user), class: 
'btn btn-danger' %>
  <% else %>
  <%= link_to "Follow", follow_user_path(@user), class: 'btn 
btn-success' %>
  <% end %>
  <% end %>

-- 
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+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/5d22c91cb01b3b3b43293d7625e4e64d%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Re: form_for @object with carrierwave upload form

2016-01-22 Thread fugee ohu
This is a broader issue than just file uploads anyway so I need to learn 
this, if you read the link I posted they make carrierwave sound good so i 
wanna get comfortable with using it 

On Friday, January 22, 2016 at 9:20:04 PM UTC-5, Przemek Kosakowski wrote:
>
> Are you using Paperclip or other gem ? I'm asking because Paperclip 
> resolved this issue and you don't have think about this other fields and 
> values.
>
>
> W dniu 23.01.2016 o 03:17, fugee ohu pisze:
>
> How do i get the values for imageable_id and imageable_type inserted into 
> a new picture object? i can put imageable_type as a hidden field, but 
> imageable_id i don't know
>
> On Thursday, January 21, 2016 at 11:16:40 PM UTC-5, fugee ohu wrote: 
>>
>> This form raises undefined method `pictures_path' for 
>> #<#:0xbb9cb4c>
>>
>> <%= form_for(@picture, :html => { :multipart => true }) do |f| %>
>>
>>   
>> <%= f.file_field :image %>
>>   
>>
>>   <%= f.submit %>
>>
>> <% end %>
>>
>>
>> -- 
> 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-ta...@googlegroups.com .
> To post to this group, send email to rubyonra...@googlegroups.com 
> .
> To view this discussion on the web visit 
> 
> https://groups.google.com/d/msgid/rubyonrails-talk/920d481a-fc83-443f-afb6-99e20e1863ff%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/d97050c0-de3b-4497-a4f7-0fda3564831f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Re: form_for @object with carrierwave upload form

2016-01-22 Thread fugee ohu
On Thursday, January 21, 2016 at 11:16:40 PM UTC-5, fugee ohu wrote:
>
> This form raises undefined method `pictures_path' for 
> #<#:0xbb9cb4c>
>
> <%= form_for(@picture, :html => { :multipart => true }) do |f| %>
>
>   
> <%= f.file_field :image %>
>   
>
>   <%= f.submit %>
>
> <% end %>
>
>
>
 I'm staying the course with carrierwave because I wanna learn to use it 
because of what I read here 
https://infinum.co/the-capsized-eight/articles/best-rails-image-uploader-paperclip-carrierwave-refile
 

-- 
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/f7f6cd00-cfee-4da2-8c3e-d759a6382441%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Re: form_for @object with carrierwave upload form

2016-01-22 Thread fugee ohu
I'm using carrierwave In my controller I can test for the presence of 
params[profile_id] and then i would know the value of imageable_type should 
be set to profile but how do i pass a value for imageable_id ?

On Friday, January 22, 2016 at 9:20:04 PM UTC-5, Przemek Kosakowski wrote:
>
> Are you using Paperclip or other gem ? I'm asking because Paperclip 
> resolved this issue and you don't have think about this other fields and 
> values.
>
>
> W dniu 23.01.2016 o 03:17, fugee ohu pisze:
>
> How do i get the values for imageable_id and imageable_type inserted into 
> a new picture object? i can put imageable_type as a hidden field, but 
> imageable_id i don't know
>
> On Thursday, January 21, 2016 at 11:16:40 PM UTC-5, fugee ohu wrote: 
>>
>> This form raises undefined method `pictures_path' for 
>> #<#:0xbb9cb4c>
>>
>> <%= form_for(@picture, :html => { :multipart => true }) do |f| %>
>>
>>   
>> <%= f.file_field :image %>
>>   
>>
>>   <%= f.submit %>
>>
>> <% end %>
>>
>>
>> -- 
> 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-ta...@googlegroups.com .
> To post to this group, send email to rubyonra...@googlegroups.com 
> .
> To view this discussion on the web visit 
> 
> https://groups.google.com/d/msgid/rubyonrails-talk/920d481a-fc83-443f-afb6-99e20e1863ff%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/24627943-9494-4959-8d57-8726a6627122%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Re: form_for @object with carrierwave upload form

2016-01-22 Thread Przemek Kosakowski
Are you using Paperclip or other gem ? I'm asking because Paperclip 
resolved this issue and you don't have think about this other fields and 
values.



W dniu 23.01.2016 o 03:17, fugee ohu pisze:
How do i get the values for imageable_id and imageable_type inserted 
into a new picture object? i can put imageable_type as a hidden field, 
but imageable_id i don't know


On Thursday, January 21, 2016 at 11:16:40 PM UTC-5, fugee ohu wrote:

This form raises |undefined method `pictures_path' for
#<#:0xbb9cb4c>|

<%= form_for(@picture, :html => { :multipart => true }) do |f| %>

  
<%= f.file_field :image %>
  

  <%= f.submit %>

<% end %>


--
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/920d481a-fc83-443f-afb6-99e20e1863ff%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/56A2E30F.4000501%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Re: form_for @object with carrierwave upload form

2016-01-22 Thread fugee ohu
How do i get the values for imageable_id and imageable_type inserted into a 
new picture object? i can put imageable_type as a hidden field, but 
imageable_id i don't know

On Thursday, January 21, 2016 at 11:16:40 PM UTC-5, fugee ohu wrote:
>
> This form raises undefined method `pictures_path' for 
> #<#:0xbb9cb4c>
>
> <%= form_for(@picture, :html => { :multipart => true }) do |f| %>
>
>   
> <%= f.file_field :image %>
>   
>
>   <%= f.submit %>
>
> <% end %>
>
>
>

-- 
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/920d481a-fc83-443f-afb6-99e20e1863ff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] polymorphic associations

2016-01-22 Thread fugee ohu
my profile model  has_many :pictures, as: :imageable and so do several 
other models
my picture model  belongs_to :imageable, polymorphic: true
in the pictures table fields imageable_id and imageable_type have both been 
migrated
ok now i create a new_user_profile_picture how are the values for 
imageable_id and imageable_type gonna be inserted into the pictures table 
please? ~ thanks

-- 
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/fe58d207-ad71-4bb1-b1b1-64e7b7d30628%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] form_for @object with carrierwave upload form

2016-01-22 Thread fugee ohu
On Friday, January 22, 2016 at 5:15:10 PM UTC-5, Walter Lee Davis wrote:
>
>
> > On Jan 22, 2016, at 1:55 PM, fugee ohu > 
> wrote: 
> > 
> > 
> > 
> > On Thursday, January 21, 2016 at 11:16:40 PM UTC-5, fugee ohu wrote: 
> > This form raises undefined method `pictures_path' for 
> #<#:0xbb9cb4c> 
> > 
> > <%= form_for(@picture, :html => { :multipart => true }) do |f| %> 
> > 
> >
> > <%= f.file_field :image %> 
> >
> > 
> >   <%= f.submit %> 
> > 
> > <% end %> 
> > 
> > 
> > 
> > the docs for paperclip describe as being used for attachments, in my 
> case i'm just uploading files not as attachments 
>
> When they refer to attachments in Paperclip, what they mean is that you 
> are attaching a file to a Rails model instance. The model instance is saved 
> in the database, and the file in the filesystem, so it is an attachment if 
> you look at it the way they mean you to. 
>
> Walter 
>
> > 
> > -- 
> > 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-ta...@googlegroups.com . 
> > To post to this group, send email to rubyonra...@googlegroups.com 
> . 
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/e4269bd0-2129-42c0-bd4b-0e88572a468b%40googlegroups.com.
>  
>
> > For more options, visit https://groups.google.com/d/optout. 
>
>   ty 

-- 
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/5f56c93d-2a04-4e5c-91ba-727f3dac3050%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] form_for @object with carrierwave upload form

2016-01-22 Thread Walter Lee Davis

> On Jan 22, 2016, at 1:55 PM, fugee ohu  wrote:
> 
> 
> 
> On Thursday, January 21, 2016 at 11:16:40 PM UTC-5, fugee ohu wrote:
> This form raises undefined method `pictures_path' for 
> #<#:0xbb9cb4c>
> 
> <%= form_for(@picture, :html => { :multipart => true }) do |f| %>
> 
>   
> <%= f.file_field :image %>
>   
> 
>   <%= f.submit %>
> 
> <% end %>
> 
> 
> 
> the docs for paperclip describe as being used for attachments, in my case i'm 
> just uploading files not as attachments 

When they refer to attachments in Paperclip, what they mean is that you are 
attaching a file to a Rails model instance. The model instance is saved in the 
database, and the file in the filesystem, so it is an attachment if you look at 
it the way they mean you to.

Walter

> 
> -- 
> 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/e4269bd0-2129-42c0-bd4b-0e88572a468b%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/6D34EDDA-4F07-4D93-B318-8A944C94E656%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Re: Has anyone setup Acts_as_Follower Gem Successfully?

2016-01-22 Thread David Williams
Matt Jones wrote in post #1180799:


They don't have an updated wiki for the gem on Rails 4. Maybe, you and I 
can put one together to solve this problem for once and for all.

-- 
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+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/48a514e77bae2ce2b48522583cce2395%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Re: form_for @object with carrierwave upload form

2016-01-22 Thread fugee ohu


On Thursday, January 21, 2016 at 11:16:40 PM UTC-5, fugee ohu wrote:
>
> This form raises undefined method `pictures_path' for 
> #<#:0xbb9cb4c>
>
> <%= form_for(@picture, :html => { :multipart => true }) do |f| %>
>
>   
> <%= f.file_field :image %>
>   
>
>   <%= f.submit %>
>
> <% end %>
>
>
>
the docs for paperclip describe as being used for attachments, in my case 
i'm just uploading files not as attachments 

-- 
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/e4269bd0-2129-42c0-bd4b-0e88572a468b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Re: Has anyone setup Acts_as_Follower Gem Successfully?

2016-01-22 Thread David Williams
Matt Jones wrote in post #1180799:
> On Thursday, 21 January 2016 22:21:37 UTC-6, Ruby-Forum.com User wrote:
>> class FollowsController < ApplicationController
>>
>>
>> <% end %>
>> the @user instead.
> The behavior you've described doesn't match the code. The `:locals => {
> :user => @user }` part of those render calls should have made `user`
> available in the partial. If you're switching to using the instance
> variable, make sure to remove all the references to the local variable
> (there's still one in the call to `user_follow_path`).
>
>

Can you help me re-write the solution?

<% if user_signed_in? %>
<% unless @user == current_user %>
<% if current_user.following?(@user) %>
<%= button_to('Stop Following', 
user_follow_path(current_user.get_follow(@user)), :method => :delete, 
:remote => true, class: 'btn btn-danger-outline') %>
<% else %>
<%= button_to('Follow', user_follows_path(@user), :remote => 
true, class: 'btn btn-success-outline') %>
<% end %>
<% end %>
<% end %>


create.js.erb
$('#follow_user').html('<%= escape_javascript(render :partial => 
"follows/follow_user") %>');

destroy.js.erb
$('#follow_user').html('<%= escape_javascript(render :partial => 
"follows/follow_user") %>');
__

I'm getting this error now

ActionView::Template::Error (undefined method `id' for nil:NilClass):
1: <% if user_signed_in? %>
2: <% unless @user == current_user %>
3: <% if current_user.following?(@user) %>
4: <%= button_to('Stop Following', 
user_follow_path(current_user.get_follow(@user)), :method => :delete, 
:remote => true, class: 'btn btn-danger-outline') %>
5: <% else %>
6: <%= button_to('Follow', user_follows_path(@user), 
:remote => true, class: 'btn btn-success-outline') %>




--
Can you try to come up with a better approach, and then show me how I 
should solve this problem? I know that it's checking for the user id, 
but the user may not be loaded yet.

-- 
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+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/339254fabe9f5a32b25ef8aeb9def9b4%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Re: form_for @object with carrierwave upload form

2016-01-22 Thread fugee ohu
On Thursday, January 21, 2016 at 11:16:40 PM UTC-5, fugee ohu wrote:
>
> This form raises undefined method `pictures_path' for 
> #<#:0xbb9cb4c>
>
> <%= form_for(@picture, :html => { :multipart => true }) do |f| %>
>
>   
> <%= f.file_field :image %>
>   
>
>   <%= f.submit %>
>
> <% end %>
>
>
>
And how is the file supposed to actually get uploaded, i changed the create 
action in my pictures controller to look like this but the file didn't get 
uploaded

  def create
@picture = Picture.new(picture_params)
if @picture.save
  uploader = PictureUploader.new
  picture = params[:imageable]
  uploader.store!(picture)
  redirect_to user_profile_path(current_user.id, 
current_user.profile.id), notice: "The picture #{@picture.name} has been 
uploaded."
else
  render "new"
end
  end 


-- 
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/17bddc41-a9ad-4cc3-bf55-1abeb67d41c1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Re: form_for @object with carrierwave upload form

2016-01-22 Thread fugee ohu
On Thursday, January 21, 2016 at 11:16:40 PM UTC-5, fugee ohu wrote:
>
> This form raises undefined method `pictures_path' for 
> #<#:0xbb9cb4c>
>
> <%= form_for(@picture, :html => { :multipart => true }) do |f| %>
>
>   
> <%= f.file_field :image %>
>   
>
>   <%= f.submit %>
>
> <% end %>
>
>
>
And how does the file actually get uploaded? I have to add code to my 
controller to upload the file? If yes, what do i need the uploader for? 

-- 
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/79928906-e5f0-4d6c-97e1-60f519197252%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Re: Has anyone setup Acts_as_Follower Gem Successfully?

2016-01-22 Thread Matt Jones


On Thursday, 21 January 2016 22:21:37 UTC-6, Ruby-Forum.com User wrote:
>
> Matt Jones wrote in post #1180578: 
> > On Tuesday, 12 January 2016 00:12:04 UTC-5, Ruby-Forum.com User wrote: 
> >> follow to unfollow. 
> >> 
>
> I'm returning for your advice and help. I've implemented a 
> Follows_Controller.Rb Below 
>
>
> class FollowsController < ApplicationController 
>   def create 
> @user = User.find(params[:user_id]) 
> current_user.follow(@user) unless current_user.blocked?(@user) 
>   end 
>
>   def destroy 
> @user = User.find(params[:user_id]) 
> current_user.stop_following(@user) 
>   end 
> end 
>
>
> The JavaScript create and destroy files for the AJAX buttons. 
>
> create.js.erb 
> $('#follow_user').html('<%= escape_javascript(render :partial => 
> "follows/follow_user", :locals => {:user => @user}) %>'); 
>
> destroy.js.erb 
> $('#follow_user').html('<%= escape_javascript(render :partial => 
> "follows/follow_user", :locals => {:user => @user}) %>'); 
>
> The follow user partial file. 
> <% if user_signed_in? %> 
> <% unless @user == current_user %> 
> <% if current_user.following?(@user) %> 
> <%= button_to('Stop Following', user_follow_path(user, 
> current_user.get_follow(@user).id), :method => :delete, :remote => true, 
> class: 'btn btn-danger-outline') %> 
> <% else %> 
> <%= button_to('Follow', user_follows_path(@user), :remote => 
> true, class: 'btn btn-success-outline') %> 
> <% end %> 
> <% end %> 
> <% end %> 
>
>
> Lastly, the routes. 
> resources :follows, :only => [:create, :destroy] 
>
>
> When I render the partial inside of the _posts.html.erb file, it gives 
> me an error. First it was 'user' method cannot be found, and then I used 
> the @user instead.


The behavior you've described doesn't match the code. The `:locals => { 
:user => @user }` part of those render calls should have made `user` 
available in the partial. If you're switching to using the instance 
variable, make sure to remove all the references to the local variable 
(there's still one in the call to `user_follow_path`).


Afterwards it started to say undefined method id for 
> nil:NilClass. Why am I unable to use the follow/unfollow buttons? 
>

That message isn't particularly helpful without a stack trace; something is 
calling `id` on an object that's nil. A stack trace would be helpful for 
finding the cause.

Regarding your followup message ("I want the buttons to show, but only 
redirect users that are not logged in."), that may require some rethinking 
of your approach. Doing a redirect from the `FollowsController#create` 
method will not do what you want (the browser will follow the redirect and 
attempt to parse the result as Javascript).

--Matt Jones

-- 
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/8a352428-2150-4646-96c2-a00aaaf1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Re: form_for @object with carrierwave upload form

2016-01-22 Thread fugee ohu
On Friday, January 22, 2016 at 6:11:34 AM UTC-5, Przemek Kosakowski wrote:
>
> Many pictures for user profile ? I can't agree but okay. If you have many 
> pictures for one user then you should create Gallery model instead of 
> Picture. Even on fb user be able to have only one profile picture. 
>
> But I don't judge, maybe your solution is effective.
>
>
> W dniu 22.01.2016 o 12:06, fugee ohu pisze:
>
> On Friday, January 22, 2016 at 6:01:33 AM UTC-5, Przemek Kosakowski wrote: 
>>
>> many pictures you mean "a few different user profile photo" or you mean 
>> "few copy of the same picture but different size/dimension" ?
>>
>> W dniu 22.01.2016 o 11:59, fugee ohu pisze:
>>
>> On Thursday, January 21, 2016 at 11:16:40 PM UTC-5, fugee ohu wrote: 
>>>
>>> This form raises undefined method `pictures_path' for 
>>> #<#:0xbb9cb4c>
>>>
>>> <%= form_for(@picture, :html => { :multipart => true }) do |f| %>
>>>
>>>   
>>> <%= f.file_field :image %>
>>>   
>>>
>>>   <%= f.submit %>
>>>
>>> <% end %>
>>>
>>>
>>>
>>   thanks, add column picture to the profile model? profiles can have many 
>> pictures 
>> -- 
>> 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-ta...@googlegroups.com.
>> To post to this group, send email to rubyonra...@googlegroups.com.
>> To view this discussion on the web visit 
>> 
>> https://groups.google.com/d/
>> msgid/rubyonrails-talk/5b59e848-b53e-453a-a68f-9a5d335dce49%40googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
>  Many pictures, not just different versions of the same picture 
> -- 
> 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-ta...@googlegroups.com .
> To post to this group, send email to rubyonra...@googlegroups.com 
> .
> To view this discussion on the web visit 
> 
> https://groups.google.com/d/msgid/rubyonrails-talk/7b78c961-db70-4905-8513-cf8d0fe82d11%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>
Yes, I'm using bootstrap-image-gallery (an extension of bluimp) Where would 
I see the table definition for Gallery model? 
 

-- 
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/08d9c13f-a691-4c98-9e60-e3a4a7b73e3a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Dynamic Fields and Models Architecture

2016-01-22 Thread Usman Shahid
Ok, i'll explain this with a hypothetical scenario. Suppose the requirement
is that we need to create a portal to provide stats of different products
available in the market. And suppose you get data periodically from
different places in spreadsheets.Each spreadsheet contains data for one
kind of product, e.g cellphones, television etc and each kind of product
has different fields. There can be hundreds of thousands of records in one
spreadsheet so it must structured for efficient retrieval, however data is
read-only, there'll be no write operations.On each data set we need to be
able to perform generic, predefined read operations. e.g. selection of
subsets fulfilling certain criteria, sorting, grouping, aggregates. For
example, I should be able to write a generic functions, which gets table
name, field name and returns count of unique values in that field. this can
be used to count televisions with different resolutions and also to count
books by different authors. here resolution and author is unique field of
respective datasets.

The problem I'm facing is that I've to create a different tables and
respective models every time a new product type is added. Even though the
models are essentially performing the same operations.

Thanks for the response.

Regards,
Usman

On 22 January 2016 at 00:33, Walter Lee Davis  wrote:

>
> > On Jan 21, 2016, at 2:25 PM, Usman Shahid 
> wrote:
> >
> > It's not a performance issue. the problem is that i don't have one
> database, but multiple databases added at run-time. Each database is
> independent and I don't know what they look like however, i need to perform
> similar operation on each of them like taking averages, min, max, count,
> selections and other read operations. I want to be able to do this without
> making any changes to code when a new database is added. I'm thinking of
> going with a schema-less JSON based approach.
>
> How does that work? How are the databases added while the app is running?
> What does the adding? There's nothing in Rails itself that is going to help
> you do this (as far as I know). If the databases are being added by another
> process while the Rails app is running (remember -- production Rails apps
> only scan the database for structure once, at startup) then you're going to
> need that other process to kick off some notification to your Rails app so
> that it can be forced to reload and get the new structure. Otherwise, what
> it sounds like you need is some abstraction layer above the database layer
> so that you can talk to that through a single API, rather than relying on
> ActiveRecord for this. There's nothing magical about JSON or NoSQL storage
> engines for this, either. If it quacks like ActiveRecord, then it's
> designed to export its structure during app startup, and stick to that
> structure while it is running.
>
> Walter
>
> >
> > On 21 January 2016 at 19:24, Walter Lee Davis 
> wrote:
> > > On Jan 20, 2016, at 2:04 PM, Usman Shahid 
> wrote:
> > >
> > > Hi Everyone,
> > >
> > > I've to design a system in which different datasets are added
> periodically to the system and user should be able to perform several
> predefined set of operations on the data. Datasets are large enough so it
> makes sense to keep them in separate tables/databases for performance
> reasons.
> > >
> > > The problem I'm facing is that how does it fit into rails ActiveRecord
> architecture. Do I generate new Models for newly generated tables every
> time a new dataset is added? Suppose even if i'm able to somehow do that, I
> still need to provide a generic interface for all datasets. I'm not sure
> what the architecture should look like while following the rails
> conventions? Also it is preferable to add new datasets without having to
> worry about changing the code.
> > >
> > > Any kind of help will be appreciated
> >
> > I would take a serious look at views or materialized views, if these are
> reporting data rather than something your users will be adding rows to.
> That would let you abstract away the implementation details of the database
> layer from your application. You have a single stable model, and its
> "table" is a SQL view of one or more actual tables in the DB. We use this
> all the time for read-only data.
> >
> > Walter
> >
> > >
> > > Regards,
> > > Usman
> > >
> > > --
> > > 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/c9a62d62-46f9-4a9b-b47a-d2729836d9d2%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"

Re: [Rails] form_for @object with carrierwave upload form

2016-01-22 Thread Colin Law
On 22 January 2016 at 10:20, fugee ohu  wrote:
> On Friday, January 22, 2016 at 5:16:55 AM UTC-5, Colin Law wrote:
>>
>> On 22 January 2016 at 04:16, fugee ohu  wrote:
>> > This form raises undefined method `pictures_path' for
>> > #<#:0xbb9cb4c>
>> >
>> > <%= form_for(@picture, :html => { :multipart => true }) do |f| %>
>>
>> Have you defined that route in routes.rb (via resources: pictures for
>> example)?
>>
>> I agree with Przemek that you would probably be better off using
>> paperclip for uploading.  It makes life very easy.
>>
>> Colin
>
>
> I wouldn't disagree   Here's the route:   post
> 'users/:id/profiles/:id/pictures/new' => 'pictures#new'

#new is the method used for showing the form, and is a get not a post,
 form_for needs the route for posting to the create method.  If you
don't supply a url in the call of form_for it assumes pictures_path
which must have been provided using resources: pictures for at least
the create method.  See [1] for details.  I expect that is described
in the Rails Guides also.

[1] http://apidock.com/rails/ActionView/Helpers/FormHelper/form_for

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%3D0gLusq6NuN9ExUgcBTooNXu%3DACdurNN7k0LPFUC_EO_UbAw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Pb with render to breaking out of an iframe

2016-01-22 Thread Jer
Hi,

I have an application who open an other web site in an iframe where my 
users have some work to do and have to clic on a button when the job is 
done.
This action send me a get http.
In the controller I use this command to breaking out of the iframe :

render :text => breakout_path(refinery.scores_score_path(@score)) , 
content_type: :html

private
  def breakout_path(path)
"parent.location.href = '#{path}';"
  end

My problem is that solution works fine on Firefox and Safari but fails in 
Chrome, IE and Opera.

In Chrome and Opera, the iframe stay and print the text render interpreted :

parent.location.href = '/scores/18';

For Internet Explorer it's worst, on clic it ask to dowload a file where 
the name is the controller name and contain the text interpreted too.

I tried to change my  into . Same behaviors.

Here is my environnement :
Ubuntu desktop 14.04
Rails 4.2.4
Ruby 2.0.0p645
Refinerycms 3.0

Thanks for helping me ;) I'm a beginner in web and rails development :\
Jer

-- 
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/afc5350b-d7ce-47d5-a4bc-f64c99f5a1ea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Re: form_for @object with carrierwave upload form

2016-01-22 Thread Przemek Kosakowski
Many pictures for user profile ? I can't agree but okay. If you have 
many pictures for one user then you should create Gallery model instead 
of Picture. Even on fb user be able to have only one profile picture.


But I don't judge, maybe your solution is effective.


W dniu 22.01.2016 o 12:06, fugee ohu pisze:
On Friday, January 22, 2016 at 6:01:33 AM UTC-5, Przemek Kosakowski 
wrote:


many pictures you mean "a few different user profile photo" or you
mean "few copy of the same picture but different size/dimension" ?

W dniu 22.01.2016 o 11:59, fugee ohu pisze:

On Thursday, January 21, 2016 at 11:16:40 PM UTC-5, fugee ohu wrote:

This form raises |undefined method `pictures_path' for
#<#:0xbb9cb4c>|

<%= form_for(@picture, :html => { :multipart => true }) do |f| %>

  
<%= f.file_field :image %>
  

  <%= f.submit %>

<% end %>



  thanks, add column picture to the profile model? profiles can
have many pictures
-- 
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-ta...@googlegroups.com .
To post to this group, send email to rubyonra...@googlegroups.com
.
To view this discussion on the web visit

https://groups.google.com/d/msgid/rubyonrails-talk/5b59e848-b53e-453a-a68f-9a5d335dce49%40googlegroups.com

.
For more options, visit https://groups.google.com/d/optout
.



 Many pictures, not just different versions of the same picture
--
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/7b78c961-db70-4905-8513-cf8d0fe82d11%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/56A20E37.2000706%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Re: form_for @object with carrierwave upload form

2016-01-22 Thread fugee ohu
On Friday, January 22, 2016 at 6:01:33 AM UTC-5, Przemek Kosakowski wrote:
>
> many pictures you mean "a few different user profile photo" or you mean 
> "few copy of the same picture but different size/dimension" ?
>
> W dniu 22.01.2016 o 11:59, fugee ohu pisze:
>
> On Thursday, January 21, 2016 at 11:16:40 PM UTC-5, fugee ohu wrote: 
>>
>> This form raises undefined method `pictures_path' for 
>> #<#:0xbb9cb4c>
>>
>> <%= form_for(@picture, :html => { :multipart => true }) do |f| %>
>>
>>   
>> <%= f.file_field :image %>
>>   
>>
>>   <%= f.submit %>
>>
>> <% end %>
>>
>>
>>
>   thanks, add column picture to the profile model? profiles can have many 
> pictures 
> -- 
> 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-ta...@googlegroups.com .
> To post to this group, send email to rubyonra...@googlegroups.com 
> .
> To view this discussion on the web visit 
> 
> https://groups.google.com/d/msgid/rubyonrails-talk/5b59e848-b53e-453a-a68f-9a5d335dce49%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>
 Many pictures, not just different versions of the same picture 

-- 
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/7b78c961-db70-4905-8513-cf8d0fe82d11%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Re: form_for @object with carrierwave upload form

2016-01-22 Thread Przemek Kosakowski
many pictures you mean "a few different user profile photo" or you mean 
"few copy of the same picture but different size/dimension" ?


W dniu 22.01.2016 o 11:59, fugee ohu pisze:

On Thursday, January 21, 2016 at 11:16:40 PM UTC-5, fugee ohu wrote:

This form raises |undefined method `pictures_path' for
#<#:0xbb9cb4c>|

<%= form_for(@picture, :html => { :multipart => true }) do |f| %>

  
<%= f.file_field :image %>
  

  <%= f.submit %>

<% end %>



  thanks, add column picture to the profile model? profiles can have 
many pictures

--
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/5b59e848-b53e-453a-a68f-9a5d335dce49%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/56A20BF6.8060903%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Re: form_for @object with carrierwave upload form

2016-01-22 Thread fugee ohu
On Thursday, January 21, 2016 at 11:16:40 PM UTC-5, fugee ohu wrote:
>
> This form raises undefined method `pictures_path' for 
> #<#:0xbb9cb4c>
>
> <%= form_for(@picture, :html => { :multipart => true }) do |f| %>
>
>   
> <%= f.file_field :image %>
>   
>
>   <%= f.submit %>
>
> <% end %>
>
>
>
  thanks, add column picture to the profile model? profiles can have many 
pictures 

-- 
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/5b59e848-b53e-453a-a68f-9a5d335dce49%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] form_for @object with carrierwave upload form

2016-01-22 Thread nanaya
Hi,

On Fri, Jan 22, 2016, at 19:20, fugee ohu wrote:
> On Friday, January 22, 2016 at 5:16:55 AM UTC-5, Colin Law wrote:
> >
> > On 22 January 2016 at 04:16, fugee ohu > 
> > wrote: 
> > > This form raises undefined method `pictures_path' for 
> > > #<#:0xbb9cb4c> 
> > > 
> > > <%= form_for(@picture, :html => { :multipart => true }) do |f| %> 
> >
> > Have you defined that route in routes.rb (via resources: pictures for 
> > example)? 
> >
> > I agree with Przemek that you would probably be better off using 
> > paperclip for uploading.  It makes life very easy. 
> >
> > Colin 
> >
> 
> I wouldn't disagree   Here's the route:   post 
> 'users/:id/profiles/:id/pictures/new' => 'pictures#new' 
> 

That route doesn't add the `pictures_path` named route. Try adding `as:
'pictures'` option.

Also note that neither the action name nor route you specified follows
rails standard convention[1].

[1] http://guides.rubyonrails.org/routing.html#crud-verbs-and-actions

-- 
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/1453459150.3567674.499468994.152475FC%40webmail.messagingengine.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] form_for @object with carrierwave upload form

2016-01-22 Thread Przemek Kosakowski

Look on below situation:

class User < ActiveRecord::Base
has_one :profile, :autosave => true
end

class Profile < ActiveRecord::Base
belongs_to :user
has_attached_file :picture,
:styles => { medium: "300x200>", thumb: "100x100>" },
  :storage => :s3,
  :s3_credentials => Proc.new{|a| 
a.instance.s3_credentials}
validates_attachment_content_type :picture, content_type: 
/\Aimage\/.*\Z/

end

this two class + paperclip and that's enough. I think You don't need 
extra model for keeping user profile picture, you can easily add column 
"picture" in Your Profile model.


W dniu 22.01.2016 o 11:20, fugee ohu pisze:

On Friday, January 22, 2016 at 5:16:55 AM UTC-5, Colin Law wrote:

On 22 January 2016 at 04:16, fugee ohu > wrote:
> This form raises undefined method `pictures_path' for
> #<#:0xbb9cb4c>
>
> <%= form_for(@picture, :html => { :multipart => true }) do |f| %>

Have you defined that route in routes.rb (via resources: pictures
for example)?

I agree with Przemek that you would probably be better off using
paperclip for uploading.  It makes life very easy.

Colin


I wouldn't disagree   Here's the route:   post 
'users/:id/profiles/:id/pictures/new' => 'pictures#new'

--
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/23941c73-ce4d-4423-9f3d-be963bd4c363%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/56A2041D.8020302%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] form_for @object with carrierwave upload form

2016-01-22 Thread fugee ohu
On Friday, January 22, 2016 at 5:16:55 AM UTC-5, Colin Law wrote:
>
> On 22 January 2016 at 04:16, fugee ohu > 
> wrote: 
> > This form raises undefined method `pictures_path' for 
> > #<#:0xbb9cb4c> 
> > 
> > <%= form_for(@picture, :html => { :multipart => true }) do |f| %> 
>
> Have you defined that route in routes.rb (via resources: pictures for 
> example)? 
>
> I agree with Przemek that you would probably be better off using 
> paperclip for uploading.  It makes life very easy. 
>
> Colin 
>

I wouldn't disagree   Here's the route:   post 
'users/:id/profiles/:id/pictures/new' => 'pictures#new' 

-- 
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/23941c73-ce4d-4423-9f3d-be963bd4c363%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] form_for @object with carrierwave upload form

2016-01-22 Thread fugee ohu
OK But now, the subject is carrierwave Users has_one profile; Profile 
has_many pictures as :imageable I'm totally lost, I dunno what role in the 
upload the controller's supposed to play since i have the uploader.rb

On Friday, January 22, 2016 at 4:59:26 AM UTC-5, Przemek Kosakowski wrote:
>
> I see you trying upload some picture, please use this gem [1]. You be able 
> in easy way customize your picture uploader.
>
> [1]: paperclip 
>
> Have you relation between user -> profile -> picture ?
>
> W dniu 22.01.2016 o 10:40, fugee ohu pisze:
>
>
>
> On Thursday, January 21, 2016 at 11:40:30 PM UTC-5, Przemek Kosakowski 
> wrote: 
>>
>> Hello,
>>
>> can you show your model and controller file ?
>>
> class PicturesController < ApplicationController
>   def index
> @pictures = Picture.all
>   end
>
>   def new
>@picture = current_user.profile.pictures.new
>   end
>
>   def create
> @picture = Picture.new(picture_params)
>
> if @picture.save
>   redirect_to current_user_profile_pictures_path, notice: "The picture 
> #{@picture.name} has been uploaded."
> else
>   render "new"
> end
>   end
>
>   def destroy
> @picture = Picture.find(params[:id])
> @picture.destroy
> redirect_to current_user_profile_pictures_path, notice:  "The picture 
> #{@picture.name} has been deleted."
>   end
>
> =
> class Picture < ActiveRecord::Base
>  belongs_to :imageable, polymorphic: true
>  mount_uploader :imageable, PictureUploader
>  validates :name, presence: true
> end
>
> private
>   def picture_params
> params.require(:picture).permit(:name, :attachment)
>   end
> end
>  
>
>>
>> W dniu 22.01.2016 o 05:16, fugee ohu pisze:
>>
>> This form raises undefined method `pictures_path' for 
>> #<#:0xbb9cb4c>
>>
>> <%= form_for(@picture, :html => { :multipart => true }) do |f| %>
>>
>>   
>> <%= f.file_field :image %>
>>   
>>
>>   <%= f.submit %>
>>
>> <% end %>
>>
>>
>> -- 
>> 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-ta...@googlegroups.com.
>> To post to this group, send email to rubyonra...@googlegroups.com.
>> To view this discussion on the web visit 
>> 
>> https://groups.google.com/d/
>> msgid/rubyonrails-talk/345bb1b7-2849-4271-92e3-59c228d2c596%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-ta...@googlegroups.com .
> To post to this group, send email to rubyonra...@googlegroups.com 
> .
> To view this discussion on the web visit 
> 
> https://groups.google.com/d/msgid/rubyonrails-talk/c3e21d24-f4fd-4adf-a32c-166aff0bb2dc%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/e5d5fdd8-0e64-4702-ba1c-9e8edf1eabb0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] form_for @object with carrierwave upload form

2016-01-22 Thread Colin Law
On 22 January 2016 at 04:16, fugee ohu  wrote:
> This form raises undefined method `pictures_path' for
> #<#:0xbb9cb4c>
>
> <%= form_for(@picture, :html => { :multipart => true }) do |f| %>

Have you defined that route in routes.rb (via resources: pictures for example)?

I agree with Przemek that you would probably be better off using
paperclip for uploading.  It makes life very easy.

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%3D0gLsVrRarhG3WtxQ7pjX-Cg7tOqTw%3Dz2xnS92QtuFSxEgZQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] form_for @object with carrierwave upload form

2016-01-22 Thread Przemek Kosakowski
I see you trying upload some picture, please use this gem [1]. You be 
able in easy way customize your picture uploader.


[1]: paperclip 

Have you relation between user -> profile -> picture ?

W dniu 22.01.2016 o 10:40, fugee ohu pisze:



On Thursday, January 21, 2016 at 11:40:30 PM UTC-5, Przemek Kosakowski 
wrote:


Hello,

can you show your model and controller file ?

class PicturesController < ApplicationController
  def index
@pictures = Picture.all
  end

  def new
   @picture = current_user.profile.pictures.new
  end

  def create
@picture = Picture.new(picture_params)

if @picture.save
  redirect_to current_user_profile_pictures_path, notice: "The 
picture #{@picture.name} has been uploaded."

else
  render "new"
end
  end

  def destroy
@picture = Picture.find(params[:id])
@picture.destroy
redirect_to current_user_profile_pictures_path, notice: "The 
picture #{@picture.name} has been deleted."

  end
=
class Picture < ActiveRecord::Base
 belongs_to :imageable, polymorphic: true
 mount_uploader :imageable, PictureUploader
 validates :name, presence: true
end

private
  def picture_params
params.require(:picture).permit(:name, :attachment)
  end
end


W dniu 22.01.2016 o 05:16, fugee ohu pisze:

This form raises |undefined method `pictures_path' for
#<#:0xbb9cb4c>|

<%= form_for(@picture, :html => { :multipart => true }) do |f| %>

  
<%= f.file_field :image %>
  

  <%= f.submit %>

<% end %>


-- 
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-ta...@googlegroups.com .
To post to this group, send email to rubyonra...@googlegroups.com
.
To view this discussion on the web visit

https://groups.google.com/d/msgid/rubyonrails-talk/345bb1b7-2849-4271-92e3-59c228d2c596%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/c3e21d24-f4fd-4adf-a32c-166aff0bb2dc%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/56A1FD49.1010906%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] form_for @object with carrierwave upload form

2016-01-22 Thread fugee ohu


On Thursday, January 21, 2016 at 11:40:30 PM UTC-5, Przemek Kosakowski 
wrote:
>
> Hello,
>
> can you show your model and controller file ?
>
class PicturesController < ApplicationController
  def index
@pictures = Picture.all
  end

  def new
   @picture = current_user.profile.pictures.new
  end

  def create
@picture = Picture.new(picture_params)

if @picture.save
  redirect_to current_user_profile_pictures_path, notice: "The picture 
#{@picture.name} has been uploaded."
else
  render "new"
end
  end

  def destroy
@picture = Picture.find(params[:id])
@picture.destroy
redirect_to current_user_profile_pictures_path, notice:  "The picture 
#{@picture.name} has been deleted."
  end
=
class Picture < ActiveRecord::Base
 belongs_to :imageable, polymorphic: true
 mount_uploader :imageable, PictureUploader
 validates :name, presence: true
end

private
  def picture_params
params.require(:picture).permit(:name, :attachment)
  end
end
 

>
> W dniu 22.01.2016 o 05:16, fugee ohu pisze:
>
> This form raises undefined method `pictures_path' for 
> #<#:0xbb9cb4c>
>
> <%= form_for(@picture, :html => { :multipart => true }) do |f| %>
>
>   
> <%= f.file_field :image %>
>   
>
>   <%= f.submit %>
>
> <% end %>
>
>
> -- 
> 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-ta...@googlegroups.com .
> To post to this group, send email to rubyonra...@googlegroups.com 
> .
> To view this discussion on the web visit 
> 
> https://groups.google.com/d/msgid/rubyonrails-talk/345bb1b7-2849-4271-92e3-59c228d2c596%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/c3e21d24-f4fd-4adf-a32c-166aff0bb2dc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.