Ruby on Rails Wednesday, January 31, 2018



On Thursday, February 1, 2018 at 2:30:07 AM UTC-5, fugee ohu wrote:
I'm having find_or_create_by roll back on me in the console directly from the model I'm not providing an id, the mysql id column is autoincrement
Model.find_or_create_by(person_id: 1, picture_id:37)


Forgot to mention Model belongs_to 4 other models

--
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/e662ef65-e157-45eb-83ce-f92cfe05ab0d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



On Thursday, February 1, 2018 at 2:30:07 AM UTC-5, fugee ohu wrote:
I'm having find_or_create_by roll back on me in the console directly from the model I'm not providing an id, the mysql id column is autoincrement
Model.find_or_create_by(person_id: 1, picture_id:37)


Forgot to mention Model has 4 belongs_to_associations

--
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/ae69497b-26ac-4838-a853-4b11f87a35df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

I'm having find_or_create_by roll back on me in the console directly from the model I'm not providing an id, the mysql id column is autoincrement
Model.find_or_create_by(person_id: 1, picture_id:37)

--
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/db326225-a0e5-4341-8dd2-bea740e5791e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

I'm having find_or_create

--
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/99655628-bb4c-441f-8216-11958cde8819%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails


Hi,

You should maintain audit for this. And "acts_as_audited" gem provides an active record extension using which you can track the update , create, destroy actions on a model

thanks,
Sunanda
On Thursday, May 13, 2010 at 2:37:05 PM UTC+5:30, Vladimir Rybas wrote:
Hi all,

Is there any gem or plugin available for Users Actions Logging?
User can create, view, chage, delete some Model and other users should
be available to see the logs.

I'm ready to use some kind of observers on models, to write Events to
database.

And second question:
Should I store all Events in database? Or YAML files or something
would be preferred?

You thoughs, guys

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

--
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/235870d6-8d1a-414a-9346-1a460db85af5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails Monday, January 29, 2018

That query looks suspiciously like you might be using kaminari for pagination? If so that is what is causing this slow query. See https://github.com/kaminari/kaminari#paginating-without-issuing-select-count-query for how to solve that. I don't believe ransack ever needs to count anything.

On Thursday, October 12, 2017 at 7:17:04 AM UTC-7, der_tom wrote:
hi,

i am using ransack and i am experiencing slow queries, eg on the search sites i have a query like that:

SELECT DISTINCT COUNT(DISTINCT `tablename`.`id`) FROM `tablename` WHERE (`tablename`.`city` LIKE '%Tampa%');
~5sec

w/o distinct 
~ 6sec

w/o distinct & w/o where
~4 sec



what do you guys do? i reviewed all indexes, datatypes, memory is ok. no overload.

and yet i am feeling that i am missing something....

thx


--
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/d47efafc-ab5d-4965-aeaa-13b870d7ea8a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

I was recently experimenting with Rails 5.2, particularly the ActiveStorage bit. I was attempting to allow a file attachment (PDF) to be thumbnailed on a as a PNG using some example code I found in the documentation:

image_tag @user.file.preview(resize: "640x280")

Tracing through the resulting error, it appeared to be mired in `identify` not being able to figure out that the Tempfile that AS created at the start of the preview task was a PDF. I had all of the dependencies installed on my Mac - `mupdf` and its predicate, `xquartz`. I haven't tried this on a Linux server yet. Has anyone else gotten this to work on their Mac?

Tracing through the code in ActiveStorage, I saw that it was supposed to create a Tempfile with the dot-suffix to match the original file, but in the error, I did not see that behavior. (And I know, dot-suffixes cannot be trusted at all.) I tried looking to see what could be overriding AS's code (maybe MiniMagick?) but I could not figure it out.

Thanks in advance,

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+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/a0573738-f970-4447-91be-759f4fa33b04%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

thank you


There's this setting (in "config/environments/test.rb" for test env):

config.action_controller.allow_forgery_protection = false (default for test env)

--
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/06ff2a24-229c-431e-aed9-06f5019ed8aa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

form_with by default generates form which is submitted by an XHR request. This is why it seems that nothing happens, but if you look to the console output, you'll see that form was actually submitted.

You can make form_with to submit by a standard page refresh by using 'local' option:

<%= form_with(model: @article, local: true) do |form| %>


On Mon, Jan 29, 2018, at 17:31, Ivo Döhler wrote:
Hello,

I've read the rails introduction and followed the examples. It was quite understandable. But the form validation didn't work as expected.

My form begins with

<%= form_with(model: @article) do |form| %>
  <% if @article.errors.any? %>
...

and in the class is the validation rule:

validates :title, length: { minimum: 5 }
...

part of the controller:

def update

@article = Article.find(params[:id])

if @article.update(article_params)
redirect_to @article
else
render :edit
end
end

the problem is:

if the title is too short (for example) I can push the update-button but nothing happens. There is no reload of the page at all, no errors are shown. Is the title is long enough, the submit-button works correctly. Do I change the form_with to (scope: :article, ...) then the errors are shown.

I use Rails 5.1.4 

Thx for a response


--
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.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Hi,

On Mon, Jan 29, 2018, at 23:51, Rob Jonson wrote:
>
> however - what concerns me is that the bug triggered an exception in
> production which was not caught in test.
>
> steps to trigger the bug are
>
> 1) create an account
> 2) log out
> 3) sign in
>
> I test this explicitly in an rspec capybara test using chrome with
> javascript enabled.
> In the test, I don't get the exception.
>
> can anyone explain why?
>

There's this setting (in "config/environments/test.rb" for test env):

config.action_controller.allow_forgery_protection = false (default for test env)

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

Ruby on Rails

Hello,

I've read the rails introduction and followed the examples. It was quite understandable. But the form validation didn't work as expected.

My form begins with

<%= form_with(model: @article) do |form| %>
  <% if @article.errors.any? %>
...

and in the class is the validation rule:

validates :title, length: { minimum: 5 }
...

part of the controller:

def update

@article = Article.find(params[:id])

if @article.update(article_params)
redirect_to @article
else
render :edit
end
end

the problem is:

if the title is too short (for example) I can push the update-button but nothing happens. There is no reload of the page at all, no errors are shown. Is the title is long enough, the submit-button works correctly. Do I change the form_with to (scope: :article, ...) then the errors are shown.

I use Rails 5.1.4 

Thx for a response

--
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/29836bfe-e8ce-4ecc-a1b1-c36bbbc4e599%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

I recently added a before_action before protect_from_forgery

before_action :set_locale
protect_from_forgery with: :exception

This causes an exception when a user tries to log in with devise.

the fix is simple (protect from forgery before doing other actions)

before_action :set_locale
protect_from_forgery with: :exception, prepend: true

however - what concerns me is that the bug triggered an exception in production which was not caught in test.

steps to trigger the bug are

1) create an account
2) log out
3) sign in

I test this explicitly in an rspec capybara test using chrome with javascript enabled.
In the test, I don't get the exception.

can anyone explain why?

thanks,

Rob

--
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/7423d138-4858-424b-9f74-4ac743f69b43%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Hello! 
I have issue with Capybara Selenium Rspec testing of file upload page. 
The reason of issue is a strange http GET request from server to local folder on my local development machine. 
Here is more information about it:
https://stackoverflow.com/questions/48499129/capybara-upload-images-issue
Please, help me.

--
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/d3b35d14-bf4d-432e-bd1f-6f9258a3eded%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

[JOBS] Stowga | London, UK | ONSITE | £40-60k + Options | Full-Stack Rails Developer | stowga.com

The Opportunity
Stowga is an early stage, rapidly growing startup backed by some of the best investors in Europe and the US. We won Wired Magazine's Startup Showcase 2017 award and have just closed a £1.5m funding round. We are looking for highly motivated and intellectually-curious software engineers to join our rapidly expanding team.

About Stowga
Our platform allows warehouses to optimise their space by offering under-utilised capacity to customers who take that space without the long-term commitment of a lease. By switching the fixed cost of a lease to a variable cost we transform the economics of this $300bn global market.
We are early stage but growth and traction to date has been impressive: we built the largest database of warehouses on the planet, identified a data-driven customer acquisition model, and signed up some of the biggest names in the industry on both the retail and the warehouse side of our marketplace.
 
Team and Technology
We are gathering a world class team of technology and logistics experts to build this category-defining product. 
We like to build things that solve problems, you will not be constrained by process – we work in small product teams that take a lean approach.
Our tech team look for skilled and collaborative developers who are motivated, excited about technology and keen to consistently raise the quality of our collective work by building elegant solutions through clean, efficient and testable code.
Our core stack is Ruby on Rails, Python and Heroku. We take a data-driven approach in everything we do. From collecting, cleaning and analysing billions of trade data points for understanding demand; to using earth orbit technology to identify warehouses. This position will ideally suit a developer with the creativity to push the envelope and the drive to excel.

Who we are looking for
 - 2 or more years of commercial experience with Ruby on Rails.
 - Someone who strives to understand how lines of code translate to business value.
 - A strong communicator.
 - Knowledge of Python and an interest in data science a plus.
 
What you get from us
 - An excellent salary
 - Options in a well backed, fast growing company with big ambition.
 - 25 days holiday.
 - Training, conference and equipment budget.
 - Hack days.
 
 Please get in touch at jobs@stowga.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/79e6a524-bfc0-45b1-af28-83bc42c91186%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails Saturday, January 27, 2018



On Saturday, January 27, 2018 at 4:05:20 PM UTC-5, Colin Law wrote:
On 27 January 2018 at 20:59, fugee ohu <fuge...@gmail.com> wrote:


On Saturday, November 3, 2012 at 7:46:47 AM UTC-4, Fahim Patel wrote:

.....

You're missing a respond_to do format block 


You realise you are five years late responding to this problem.

Colin


Oh sorry I originally responded by mistake, i must have found the thread searching Then that put it in my list

--
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/8e1139ca-040a-47fe-a82c-19c02ad4050b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

ERROR: "thor csv" was called with arguments ["-i,", "-m,"] Usage: "thor datashift:import:csv -i, --input=INPUT -m, --model=MODEL"


I was using it like this:

  thor datashift_spree:load:products -i, --input=products_export.csv  

--
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/ba086930-ec47-47d8-a68c-703b7bbffc9c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On 27 January 2018 at 20:59, fugee ohu <fugee279@gmail.com> wrote:


On Saturday, November 3, 2012 at 7:46:47 AM UTC-4, Fahim Patel wrote:

.....

You're missing a respond_to do format block 


You realise you are five years late responding to this problem.

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%3D0gLsWQjdrATH8z%3DzcAT3Do-r1AZ%2BM-%3DN88NV%2ByObAzxgJZQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



On Saturday, November 3, 2012 at 7:46:47 AM UTC-4, Fahim Patel wrote:

Hi all, 


from last 1 hour i am facing one problem.

I have written a code for creating  user and show them in index page after save.

Code is working perfectly but on index page i am getting all record till second last record saved, but i am not getting current  record which is saved.

But in database my last record is saved successful.


But when i restart the server , than on index page all record come with the last record .

I dont know why this all is happening ?
Code below


######## controller code
class AdminUsersController < ApplicationController
  def new
    @admin = AdminUser.new
  end

  def index
    @admins = AdminUser.all
  end

  def create
    @admin = AdminUser.new(params[:admin_user])
    if @admin.save

      redirect_to admin_users_path
    else
      render "new"
    end
  end
end

######## new view############
<%= form_for @admin do|f|%>

First Name
<%= f.text_field :first_name%>
<%= submit_tag"Create"%>
<% end %>
######## index view############
<%= @admins%>

##############model
nothing in model



Hope you all understand the problem .


Thanks 

Regards
Fahim Babar Patel






You're missing a respond_to do format block 

--
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/e5bafa50-f324-4a7f-b735-abf362d60543%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

I used params[:...] in some views instead of @object.param by mistake but it works Can someone please explain

--
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/be8b1d81-a845-458b-b8a6-d324a5c38542%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

A mountable blog engine is usually something that lets users create blogs and then the public can view a particular users blog?

--
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/3c7f3cd2-217d-4205-bd5e-ef332d1650f5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

A mounta

--
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/22e8164a-9a97-4078-b50d-9940d488fb96%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

I'm using this gem but I don't see where the public is supposed to be able to view  a particular users blog

--
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/34b8b39a-0c66-4e6a-a1c6-3a8841b983a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



On Saturday, November 3, 2012 at 7:46:47 AM UTC-4, Fahim Patel wrote:

Hi all, 


from last 1 hour i am facing one problem.

I have written a code for creating  user and show them in index page after save.

Code is working perfectly but on index page i am getting all record till second last record saved, but i am not getting current  record which is saved.

But in database my last record is saved successful.


But when i restart the server , than on index page all record come with the last record .

I dont know why this all is happening ?
Code below


######## controller code
class AdminUsersController < ApplicationController
  def new
    @admin = AdminUser.new
  end

  def index
    @admins = AdminUser.all
  end

  def create
    @admin = AdminUser.new(params[:admin_user])
    if @admin.save

      redirect_to admin_users_path
    else
      render "new"
    end
  end
end

######## new view############
<%= form_for @admin do|f|%>

First Name
<%= f.text_field :first_name%>
<%= submit_tag"Create"%>
<% end %>
######## index view############
<%= @admins%>

##############model
nothing in model



Hope you all understand the problem .


Thanks 

Regards
Fahim Babar Patel






I have blogit working but I don't see how the public is supposed to see a particular users blog

--
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/55272766-6bcb-4d2b-8e29-65853ec113fa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



On Sunday, August 30, 2015 at 8:55:17 AM UTC-4, Sadaf Noor wrote:
Are you facing any problem deploying your app with engine? I had blogit engine in my rails app and there was nothing special about it. I just did following and it worked:

$ git push heroku master
$ heroku run bundler install

2015-08-30 16:26 GMT+06:00 L. Johan Nissen <lj.n...@googlemail.com>:
Hi guys,

I've got a Rails app that is dependent on a Rails Engine to function. I would like know how to deploy such an app to Heroku and especially if there's somebody who has made a tutorial.



Thank you in advance.

--
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/f24fab7e-ad14-480b-8508-d9a615103fd6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
 Md. Sadaf Noor (@sadaf2605)
 www.sadafnoor.com

I have blogit engine running on an app and I don't see anything for world(public) viewing of a particular users blog How's this supposed to work? 

--
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/b7eb9c1d-18d4-4afd-814e-3c9ac6d0cbc8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails Friday, January 26, 2018



On Friday, January 26, 2018 at 12:51:06 PM UTC-5, Walter Lee Davis wrote:

> On Jan 26, 2018, at 12:36 PM, fugee ohu <fuge...@gmail.com> wrote:
>
>
>
> On Friday, January 26, 2018 at 9:06:47 AM UTC-5, Walter Lee Davis wrote:
>
> > On Jan 25, 2018, at 8:41 PM, fugee ohu <fuge...@gmail.com> wrote:
> >
> > Unless i'm gonna show my ads on their pages what can my user's users do for me in a multi tenant multi user blog in terms of monetizing
>
> The whole point of software as a service is that your users pay you to be on your platform. Ads don't enter into it. You provide a full-featured set of tools for blogging, and they pay you for the convenience of using it. You improve that service over time, and they continue to pay you for it.
>
> One of the features you may provide is a one-click way to add ads to *their* blog, and choose which ads are appropriate for *their* audience. If you write that tool, and make it easy to use (and profitable for *your* users), then they will continue to pay you for the privilege of using your platform. Ideally, you should not be getting any bit of their ad revenue (except some transaction fee, if you manage the money for them). Neither should you be putting your ads (which make sense for you) into their blog (which you have never even seen, so how could you find appropriate ads?).
>
> If you do this right, then your users will make more money in ads (or at least break even) than they pay you for the service (or at least break even). If you have priced your service correctly, then your customers will not feel as though they are being ripped off, and will think that the price they pay for the convenience is worthwhile.
>
> Walter
>  
> To get money from users I'd do a different type of site like an auction, marketplace or ecommerce site I don't expect anyone to pay me to use a blogging platform Do tumblr users pay for the service or get it free?

I don't know. It's just that when you start talking about multi-tenant software, my mind goes to other problems that pattern solves, which all tend to be pay-to-use.

If you want to make a Tumblr clone, then you could just add a wrapper layout around all published blogs, and your ads would appear there. Depending on how you structure your layout and templates, that could mean header, footer, skyscrapers, almost anything except inserted within the body of the user's content. And if you control the rendering, I suppose you could even break out their content by major blocks (paragraphs, sections, whatever they use to divide their content) and insert an ad every N of those. Nokogiri is how I would do that.

How invasive you get here has to do with what sort of "free" your users are willing to put up with, I would say. If Tumblr adds a header and footer ad, and doesn't share the revenue, then that's one kind. YouTube lets content creators monetize in various ways, some of which they share with the creators, and some of which they don't, including popover ads and other nastiness that I keep removing with browser plugins. 8-)

If you write the blogging engine yourself, then you have access to all of these parts and can do pretty much whatever you want. If you're trying to coerce a blog-in-a-box gem to do this, then you'll probably have to start by reading all the code to that gem, find out where it gets it layouts and templates and partials from, and start adding those to your parent application one at a time until you find the lever you need. And if you can't get it from there, try raising an issue on that gem's Github project.

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/1d83fa66-acbb-413a-b246-735b5564b2a8%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.


I was thinking there may be a lot of blogging platforms but not a lot of multi user blogging platforms 

--
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/60c72477-34cf-40e6-b6d7-88c74a3e9166%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



On Friday, January 26, 2018 at 12:51:06 PM UTC-5, Walter Lee Davis wrote:

> On Jan 26, 2018, at 12:36 PM, fugee ohu <fuge...@gmail.com> wrote:
>
>
>
> On Friday, January 26, 2018 at 9:06:47 AM UTC-5, Walter Lee Davis wrote:
>
> > On Jan 25, 2018, at 8:41 PM, fugee ohu <fuge...@gmail.com> wrote:
> >
> > Unless i'm gonna show my ads on their pages what can my user's users do for me in a multi tenant multi user blog in terms of monetizing
>
> The whole point of software as a service is that your users pay you to be on your platform. Ads don't enter into it. You provide a full-featured set of tools for blogging, and they pay you for the convenience of using it. You improve that service over time, and they continue to pay you for it.
>
> One of the features you may provide is a one-click way to add ads to *their* blog, and choose which ads are appropriate for *their* audience. If you write that tool, and make it easy to use (and profitable for *your* users), then they will continue to pay you for the privilege of using your platform. Ideally, you should not be getting any bit of their ad revenue (except some transaction fee, if you manage the money for them). Neither should you be putting your ads (which make sense for you) into their blog (which you have never even seen, so how could you find appropriate ads?).
>
> If you do this right, then your users will make more money in ads (or at least break even) than they pay you for the service (or at least break even). If you have priced your service correctly, then your customers will not feel as though they are being ripped off, and will think that the price they pay for the convenience is worthwhile.
>
> Walter
>  
> To get money from users I'd do a different type of site like an auction, marketplace or ecommerce site I don't expect anyone to pay me to use a blogging platform Do tumblr users pay for the service or get it free?

I don't know. It's just that when you start talking about multi-tenant software, my mind goes to other problems that pattern solves, which all tend to be pay-to-use.

If you want to make a Tumblr clone, then you could just add a wrapper layout around all published blogs, and your ads would appear there. Depending on how you structure your layout and templates, that could mean header, footer, skyscrapers, almost anything except inserted within the body of the user's content. And if you control the rendering, I suppose you could even break out their content by major blocks (paragraphs, sections, whatever they use to divide their content) and insert an ad every N of those. Nokogiri is how I would do that.

How invasive you get here has to do with what sort of "free" your users are willing to put up with, I would say. If Tumblr adds a header and footer ad, and doesn't share the revenue, then that's one kind. YouTube lets content creators monetize in various ways, some of which they share with the creators, and some of which they don't, including popover ads and other nastiness that I keep removing with browser plugins. 8-)

If you write the blogging engine yourself, then you have access to all of these parts and can do pretty much whatever you want. If you're trying to coerce a blog-in-a-box gem to do this, then you'll probably have to start by reading all the code to that gem, find out where it gets it layouts and templates and partials from, and start adding those to your parent application one at a time until you find the lever you need. And if you can't get it from there, try raising an issue on that gem's Github project.

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/1d83fa66-acbb-413a-b246-735b5564b2a8%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.


Tumblr lets their users create single or multi user blogs?

--
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/457d302b-5960-44da-8fa5-3a29600966c7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Thanks Walter for the help.

On Friday, January 26, 2018 at 6:36:50 PM UTC+5:30, Prince Bansal wrote:
Hello Guys,

I faced a situation in Rails that I need current_user method inside model. There is a condition that I do not have any column that is associated 
with current_user in model. I do not want to declare virtual attribute in each activerecord model also do not want to set it in global variable. How can I achieve this?

Your help will be highly appreciated.

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+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/3b7660ee-b789-4fbb-b9ea-55dd943c8061%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

> On Jan 26, 2018, at 12:36 PM, fugee ohu <fugee279@gmail.com> wrote:
>
>
>
> On Friday, January 26, 2018 at 9:06:47 AM UTC-5, Walter Lee Davis wrote:
>
> > On Jan 25, 2018, at 8:41 PM, fugee ohu <fuge...@gmail.com> wrote:
> >
> > Unless i'm gonna show my ads on their pages what can my user's users do for me in a multi tenant multi user blog in terms of monetizing
>
> The whole point of software as a service is that your users pay you to be on your platform. Ads don't enter into it. You provide a full-featured set of tools for blogging, and they pay you for the convenience of using it. You improve that service over time, and they continue to pay you for it.
>
> One of the features you may provide is a one-click way to add ads to *their* blog, and choose which ads are appropriate for *their* audience. If you write that tool, and make it easy to use (and profitable for *your* users), then they will continue to pay you for the privilege of using your platform. Ideally, you should not be getting any bit of their ad revenue (except some transaction fee, if you manage the money for them). Neither should you be putting your ads (which make sense for you) into their blog (which you have never even seen, so how could you find appropriate ads?).
>
> If you do this right, then your users will make more money in ads (or at least break even) than they pay you for the service (or at least break even). If you have priced your service correctly, then your customers will not feel as though they are being ripped off, and will think that the price they pay for the convenience is worthwhile.
>
> Walter
>
> To get money from users I'd do a different type of site like an auction, marketplace or ecommerce site I don't expect anyone to pay me to use a blogging platform Do tumblr users pay for the service or get it free?

I don't know. It's just that when you start talking about multi-tenant software, my mind goes to other problems that pattern solves, which all tend to be pay-to-use.

If you want to make a Tumblr clone, then you could just add a wrapper layout around all published blogs, and your ads would appear there. Depending on how you structure your layout and templates, that could mean header, footer, skyscrapers, almost anything except inserted within the body of the user's content. And if you control the rendering, I suppose you could even break out their content by major blocks (paragraphs, sections, whatever they use to divide their content) and insert an ad every N of those. Nokogiri is how I would do that.

How invasive you get here has to do with what sort of "free" your users are willing to put up with, I would say. If Tumblr adds a header and footer ad, and doesn't share the revenue, then that's one kind. YouTube lets content creators monetize in various ways, some of which they share with the creators, and some of which they don't, including popover ads and other nastiness that I keep removing with browser plugins. 8-)

If you write the blogging engine yourself, then you have access to all of these parts and can do pretty much whatever you want. If you're trying to coerce a blog-in-a-box gem to do this, then you'll probably have to start by reading all the code to that gem, find out where it gets it layouts and templates and partials from, and start adding those to your parent application one at a time until you find the lever you need. And if you can't get it from there, try raising an issue on that gem's Github project.

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+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/1d83fa66-acbb-413a-b246-735b5564b2a8%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+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/54205CCA-8743-438A-ABD2-DEBDA0871216%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

> On Jan 26, 2018, at 12:36 PM, Prince Bansal <er.princebansal@gmail.com> wrote:
>
> Okay. You're not going to be able to access current_user in a model like this. There's just no notion of who is using the app in the Model context. In a controller or view, yes, you can do this (although I would recommend you use CanCanCan or Pundit to abstract the authorization away into its own domain).
>
> - There are two type of users updating this record. One with admin permission and another with area_admin. But in case of area admin I also need to check that record should not be older than 7 days. I am already using pundit for authorization.
>
> You want to think about this from the perspective of can_edit? rather than is_editable?. The former works on a user, which the controller or view would know about. The latter is specific to the instance of the model -- has it had the "publish" checkbox clicked? has an admin approved it? etc.
>
> I suspect you will keep your is_editable? method (without the user-specific stuff) and then add on to that with a can_edit? method that may in fact also invoke the is_editable? method from its target.
>
> - It means I need to remove before_save callback and simply keep is_editable method and invoke it on target object with can_edit? in controller? Right?

That could work. Another way to do this is to loop it into a validation. can_edit? could govern whether the edit button appears in the view, but if you added it to the validations, then it could also keep you from saving a record you shouldn't if you somehow manage to get the form to load (by hacking the path).

Walter

>
> On Friday, January 26, 2018 at 6:36:50 PM UTC+5:30, Prince Bansal wrote:
> Hello Guys,
>
> I faced a situation in Rails that I need current_user method inside model. There is a condition that I do not have any column that is associated
> with current_user in model. I do not want to declare virtual attribute in each activerecord model also do not want to set it in global variable. How can I achieve this?
>
> Your help will be highly appreciated.
>
> 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+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/7c51e795-9593-47d9-a3c6-99b3cc6c8cbc%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+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/471BC3D5-648A-4C22-96B3-E5A9E61DEE25%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Okay. You're not going to be able to access current_user in a model like this. There's just no notion of who is using the app in the Model context. In a controller or view, yes, you can do this (although I would recommend you use CanCanCan or Pundit to abstract the authorization away into its own domain). 

- There are two type of users updating this record. One with admin permission and another with area_admin. But in case of area admin I also need to check that record should not be older than 7 days. I am already using pundit for authorization.

You want to think about this from the perspective of can_edit? rather than is_editable?. The former works on a user, which the controller or view would know about. The latter is specific to the instance of the model -- has it had the "publish" checkbox clicked? has an admin approved it? etc. 

I suspect you will keep your is_editable? method (without the user-specific stuff) and then add on to that with a can_edit? method that may in fact also invoke the is_editable? method from its target.

- It means I need to remove before_save callback and simply keep is_editable method and invoke it on target object with can_edit? in controller? Right?

On Friday, January 26, 2018 at 6:36:50 PM UTC+5:30, Prince Bansal wrote:
Hello Guys,

I faced a situation in Rails that I need current_user method inside model. There is a condition that I do not have any column that is associated 
with current_user in model. I do not want to declare virtual attribute in each activerecord model also do not want to set it in global variable. How can I achieve this?

Your help will be highly appreciated.

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+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/7c51e795-9593-47d9-a3c6-99b3cc6c8cbc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



On Friday, January 26, 2018 at 9:06:47 AM UTC-5, Walter Lee Davis wrote:

> On Jan 25, 2018, at 8:41 PM, fugee ohu <fuge...@gmail.com> wrote:
>
> Unless i'm gonna show my ads on their pages what can my user's users do for me in a multi tenant multi user blog in terms of monetizing

The whole point of software as a service is that your users pay you to be on your platform. Ads don't enter into it. You provide a full-featured set of tools for blogging, and they pay you for the convenience of using it. You improve that service over time, and they continue to pay you for it.

One of the features you may provide is a one-click way to add ads to *their* blog, and choose which ads are appropriate for *their* audience. If you write that tool, and make it easy to use (and profitable for *your* users), then they will continue to pay you for the privilege of using your platform. Ideally, you should not be getting any bit of their ad revenue (except some transaction fee, if you manage the money for them). Neither should you be putting your ads (which make sense for you) into their blog (which you have never even seen, so how could you find appropriate ads?).

If you do this right, then your users will make more money in ads (or at least break even) than they pay you for the service (or at least break even). If you have priced your service correctly, then your customers will not feel as though they are being ripped off, and will think that the price they pay for the convenience is worthwhile.

Walter
 
To get money from users I'd do a different type of site like an auction, marketplace or ecommerce site I don't expect anyone to pay me to use a blogging platform Do tumblr users pay for the service or get it free?

--
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/1d83fa66-acbb-413a-b246-735b5564b2a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Okay. You're not going to be able to access current_user in a model like this. There's just no notion of who is using the app in the Model context. In a controller or view, yes, you can do this (although I would recommend you use CanCanCan or Pundit to abstract the authorization away into its own domain).

You want to think about this from the perspective of can_edit? rather than is_editable?. The former works on a user, which the controller or view would know about. The latter is specific to the instance of the model -- has it had the "publish" checkbox clicked? has an admin approved it? etc.

I suspect you will keep your is_editable? method (without the user-specific stuff) and then add on to that with a can_edit? method that may in fact also invoke the is_editable? method from its target.

Walter

> On Jan 26, 2018, at 11:26 AM, Prince Bansal <er.princebansal@gmail.com> wrote:
>
> Here is the code snippet.
>
> class Attendance < ApplicationRecord
>
> ATTENDANCE_EDITABLE_VALIDITY = 7
>
> before_save :is_editable?
>
> belongs_to :attendance_detail
>
> def is_editable?
> errors.add(:attendance, 'modification is not allowed.') if attendance_detail.created_at.present? && (Time.zone.now.to_date - attendance_detail.created_at.to_date).to_i >= ATTENDANCE_EDITABLE_VALIDITY unless current_user.super_admin? || current_user.admin?
> errors.empty?
> end
> end
>
> I have lots of conditional callbacks based on current_user in AR.
> I do not want to move these conditions in controller. As there are lot of other conditions that are user permission specific.
>
>
> On Friday, January 26, 2018 at 6:36:50 PM UTC+5:30, Prince Bansal wrote:
> Hello Guys,
>
> I faced a situation in Rails that I need current_user method inside model. There is a condition that I do not have any column that is associated
> with current_user in model. I do not want to declare virtual attribute in each activerecord model also do not want to set it in global variable. How can I achieve this?
>
> Your help will be highly appreciated.
>
> 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+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/06d886de-2b66-46ac-b71d-7d37981a194a%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+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/5B816BC0-5A36-4BA7-B695-D0628FDF797E%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Here is the code snippet.

class Attendance < ApplicationRecord

  ATTENDANCE_EDITABLE_VALIDITY = 7

  before_save :is_editable?

  belongs_to :attendance_detail

  def is_editable?
    errors.add(:attendance, 'modification is not allowed.') if attendance_detail.created_at.present? && (Time.zone.now.to_date - attendance_detail.created_at.to_date).to_i >= ATTENDANCE_EDITABLE_VALIDITY unless current_user.super_admin? || current_user.admin?
    errors.empty?
  end
end

I have lots of conditional callbacks based on current_user in AR.
I do not want to move these conditions in controller. As there are lot of other conditions that are user permission specific.


On Friday, January 26, 2018 at 6:36:50 PM UTC+5:30, Prince Bansal wrote:
Hello Guys,

I faced a situation in Rails that I need current_user method inside model. There is a condition that I do not have any column that is associated 
with current_user in model. I do not want to declare virtual attribute in each activerecord model also do not want to set it in global variable. How can I achieve this?

Your help will be highly appreciated.

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+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/06d886de-2b66-46ac-b71d-7d37981a194a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Devise is written to be model name agnostic. They use the reference name `resource` internally to mean User, Admin, ChiefPoobah, Peasant -- whatever you choose to call your user model. If you're not hacking on Devise, then you may need to look for a similar abstraction in what you are working on. More details would help us help you...

Walter

> On Jan 26, 2018, at 8:20 AM, Rodrigo Urubatan Ferreira Jardim <urubatan@gmail.com> wrote:
>
> Current user is a session concept, are you sure you are doing things in the correct place?
>
> Maybe you are doing something in a active record hook that should be a method called by the controller...
>
>
> Em Sex, 26 de jan de 2018 11:06, Prince Bansal <er.princebansal@gmail.com> escreveu:
> Hello Guys,
>
> I faced a situation in Rails that I need current_user method inside model. There is a condition that I do not have any column that is associated
> with current_user in model. I do not want to declare virtual attribute in each activerecord model also do not want to set it in global variable. How can I achieve this?
>
> Your help will be highly appreciated.
>
> 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+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/0bc3a8c2-8d47-4cea-b6f0-3cedd760a15c%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> Rodrigo Urubatan Ferreira Jardim
> urubatan@gmail.com / rodrigo@urubatan.com.br
> http://www.urubatan.com.br
>
> --
> 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/CAEi2OX6ZmGSM_KbKJqZBypN-M22gwTouFgCu8zFoX%3Ds1BbDibw%40mail.gmail.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+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/63CE8353-D850-47EF-942C-5131F86B7440%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Right. It's even easier for a gem. Just put your templates in the same relative place within your normal rails views or controllers, properly named, and they will "shadow" the version within the gem. In most things in Rails, "nearest wins". Gems insert their code into the Rails lookup path *after* the core application code, not before. So if you add code to the core, it will be found before the gem's code is, and Rails will stop looking at that point.

I just dealt with this last night, when I overrode the Thredded gem to make the breadcrumbs work the way I needed them to. All I had to do was add this folder:

app/views/thredded/shared

and add the _breadcrumbs.html.erb file to that folder, and I had complete control over that one file (without needing to shadow every other part of the gem).

Walter

> On Jan 26, 2018, at 7:10 AM, Mauro Locatelli <crivotz@gmail.com> wrote:
>
> Sorry I've seen now the word 'gems'
> My instructions are to make override of scaffold generator.
>
> Mauro
>
>
> 2018-01-26 13:06 GMT+01:00 Mauro Locatelli <crivotz@gmail.com>:
> Yes, you can
>
> Model
> project_folder/lib/templates/active_record/model/model.rb
>
> Controller
> project_folder/lib/templates/rails/scaffold_controller/controller.rb
>
> Views
> project_folder/lib/templates/erb/scaffold/
>
> All the original file can be founded inside railties folder (bundle show railties)
> You can also add views editing scaffold_generator.rb
>
> Cheers
> Mauro
>
> 2018-01-26 12:52 GMT+01:00 fugee ohu <fugee279@gmail.com>:
> I can override any gem's controllers and views by creating them in my app?
>
> --
> 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/51d6633b-81cc-41ef-b548-575feb06f086%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+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/CANnJYrqXiWCGi8yayXi4OCJSRxq_D4m6Er8fzBbPjf7Ak4%2BuVw%40mail.gmail.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+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/9B5539DE-AE7E-499C-88F4-7DB7B89B7925%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.